From 365b8b6db750151b786b0a7ef9e65a6824576f1b Mon Sep 17 00:00:00 2001 From: kennyj Date: Fri, 30 Mar 2012 03:51:08 +0900 Subject: Fix #5563. Should reflect the most recent change to either of association / id. --- .../test/cases/associations/belongs_to_associations_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test') 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 -- cgit v1.2.3