aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-05-18 12:47:55 -0700
committerPiotr Sarnacki <drogus@gmail.com>2012-05-19 04:06:11 -0700
commit099bb5d7b0e139d097b0c9bab4cdc8a36cf05ffa (patch)
tree6a57a0a51ed7b7a04c576320b0c0e21b1e8a603a /activerecord/test/cases/associations/has_many_associations_test.rb
parentec774983514d4ce1b593585ae14a17b730ee2c46 (diff)
downloadrails-099bb5d7b0e139d097b0c9bab4cdc8a36cf05ffa.tar.gz
rails-099bb5d7b0e139d097b0c9bab4cdc8a36cf05ffa.tar.bz2
rails-099bb5d7b0e139d097b0c9bab4cdc8a36cf05ffa.zip
Ensure that CollectionAssociation#replace returns proper target
The fix commited in e2a070c was returning the `new_target`, as a try to return whatever user replaced association with. The problem is, the resulting association target may be ordered differently. In such case we want to return the target that will be later used for that association.
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index b51f4b0786..8b384c2513 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1572,14 +1572,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [bulb2], car.reload.bulbs
end
- def test_replace_returns_new_target
+ def test_replace_returns_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])
+ result = car.bulbs.replace([bulb3, bulb1])
assert_equal [bulb1, bulb3], car.bulbs
assert_equal [bulb1, bulb3], result
end