Assertion doesn't make sense (to me)

On 5 Oct 2007, a

    # 5. Can we update through the link?     assert p.authors.first.update_attributes(:lastname => "abc") # Succeeds     assert_equal("abc", p.authors.first.lastname) # Succeeds     puts "A.Lastname: #{a.lastname}" # => <nil>     puts p.authors.first.lastname # => abc     assert_equal a, p.authors.first # Succeeds     assert_equal("abc", a.lastname) # Fails!

[/code]

The problem is in the last assertion - surely a.lastname should be set to 'abc' as we did that through the relationship from the Paper? Any help would be much appreciated, thanks.

The problem is that a contains stale data (it corresponds to the same row in the database as p.authors.first, but it's a different ruby object(. If you did a.reload before the assertion, the test should pass. The compare on active record just compares the primary key, not the attributes, which is why assert_equal a, p.authors.first

Fred