diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2015-11-23 16:22:03 +0200 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2015-11-23 16:22:03 +0200 |
commit | 6d0d83a33f59d9415685852cf77818c41e2e2700 (patch) | |
tree | cd201839897deccfc6c8ee310c292c6ec4210dcb /activerecord/test/cases | |
parent | 4547e894e9f924221f1ec4ff8e71fa750bab3595 (diff) | |
download | rails-6d0d83a33f59d9415685852cf77818c41e2e2700.tar.gz rails-6d0d83a33f59d9415685852cf77818c41e2e2700.tar.bz2 rails-6d0d83a33f59d9415685852cf77818c41e2e2700.zip |
Bugfix collection association #create method …
When same association is loaded in the model creation callback
The new object is inserted into association twice
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 6 |
1 files changed, 6 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 50ca6537cc..ad157582a4 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -2348,6 +2348,12 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal [first_bulb, second_bulb], car.bulbs end + test 'double insertion of new object to association when same association used in the after create callback of a new object' do + car = Car.create! + car.bulbs << TrickyBulb.new + assert_equal 1, car.bulbs.size + end + def test_association_force_reload_with_only_true_is_deprecated company = Company.find(1) |