diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-24 16:45:46 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-24 16:45:46 +0000 |
commit | 7d65f7cd3dbcf9a3986f0f05b692e83de6515390 (patch) | |
tree | a254f11749ba178e6fa8b34e26713ac207959935 /activerecord/test | |
parent | 943fde0a55594bb9e75783974e37eba9584ac79b (diff) | |
download | rails-7d65f7cd3dbcf9a3986f0f05b692e83de6515390.tar.gz rails-7d65f7cd3dbcf9a3986f0f05b692e83de6515390.tar.bz2 rails-7d65f7cd3dbcf9a3986f0f05b692e83de6515390.zip |
Revert [2040], caused assignment of belongs_to associations to fail in some cases
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2048 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/associations_test.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index e20477f3e2..c8dc687106 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -7,6 +7,8 @@ require 'fixtures/reply' require 'fixtures/computer' require 'fixtures/customer' require 'fixtures/order' +require 'fixtures/post' +require 'fixtures/author' # Can't declare new classes in test case methods, so tests before that bad_collection_keys = false @@ -813,12 +815,21 @@ class BelongsToAssociationsTest < Test::Unit::TestCase end def test_association_assignment_sticks - client = Client.find(:first) - apple = Firm.create("name" => "Apple") - client.firm = apple - client.save! - client.reload - assert_equal apple.id, client.firm_id + post = Post.find(:first) + author1, author2 = Author.find(:all, :limit => 2) + + # make sure the association is loaded + post.author + + # set the association by id, directly + post.author_id = author2.id + + # save and reload + post.save! + post.reload + + # the author id of the post should be the id we set + assert_equal post.author_id, author2.id end end |