aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-05-09 19:35:34 -0700
committerPiotr Sarnacki <drogus@gmail.com>2012-05-16 17:24:58 -0700
commit0f4359252fa08dfc30de21aca329cb27eddfaee5 (patch)
tree0c262a420dcae486f223e1c456a5d6cd3653067b /activerecord/test/cases/associations
parente3033e3b49cf0577221ca30e4d5507edd2802029 (diff)
downloadrails-0f4359252fa08dfc30de21aca329cb27eddfaee5.tar.gz
rails-0f4359252fa08dfc30de21aca329cb27eddfaee5.tar.bz2
rails-0f4359252fa08dfc30de21aca329cb27eddfaee5.zip
Fix CollectionAssociation#replace to return new target (closes #6231)
Conflicts: activerecord/test/cases/associations/has_many_associations_test.rb
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index f7b2b42959..a28b8e6651 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1686,4 +1686,16 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [bulb2], car.bulbs
assert_equal [bulb2], car.reload.bulbs
end
+
+ def test_replace_returns_new_target
+ car = Car.create(:name => 'honda')
+ bulb1 = car.bulbs.create
+ bulb2 = car.bulbs.create
+ bulb3 = Bulb.create
+
+ assert_equal [bulb1, bulb2], car.bulbs
+ result = car.bulbs.replace([bulb1, bulb3])
+ assert_equal [bulb1, bulb3], car.bulbs
+ assert_equal [bulb1, bulb3], result
+ end
end