aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2012-03-30 03:51:08 +0900
committerkennyj <kennyj@gmail.com>2012-04-13 02:25:19 +0900
commit365b8b6db750151b786b0a7ef9e65a6824576f1b (patch)
treee19ddad03c4792318b4f66f9c07d6ffe3e080c44 /activerecord/test/cases/associations
parent0f3901e9101837eaab2daba5b01f67ed7e2c75d5 (diff)
downloadrails-365b8b6db750151b786b0a7ef9e65a6824576f1b.tar.gz
rails-365b8b6db750151b786b0a7ef9e65a6824576f1b.tar.bz2
rails-365b8b6db750151b786b0a7ef9e65a6824576f1b.zip
Fix #5563. Should reflect the most recent change to either of association / id.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index 9dd041af81..e620b14f94 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -705,4 +705,15 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_equal toy, sponsor.reload.sponsorable
end
+
+ def test_reflect_the_most_recent_change
+ author1, author2 = Author.limit(2)
+ post = Post.new(:title => "foo", :body=> "bar")
+
+ post.author = author1
+ post.author_id = author2.id
+
+ assert post.save
+ assert_equal post.author_id, author2.id
+ end
end