require File.dirname(__FILE__) + '/../test_helper'

class AuthorTest < Test::Unit::TestCase
  fixtures :authors

  # Find an existing author
  def test_find
    author = Author.find_or_create @john_smith.attributes
    assert_equal @john_smith.id, author.id
  end

  # Entries relationship
  def test_entries
    assert_equal @john_smith.entries[0], @blue_comment
  end

  # Create a new author
  def test_create
    params = @john_smith.attributes.dup.update"name"=>"Jane Smith"
    author = Author.find_or_create params
    assert_nil author.id
    assert author.save
    assert_not_equal @john_smith.id, author.id
  end
end
