diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-12-23 21:56:20 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-12-23 21:56:20 +0900 |
commit | 9eee7822ac4bce983ad45a98c4d111eb36285199 (patch) | |
tree | 20c13d1bcc947a2b6cfc2e8ecd25714f76aca7a5 /activerecord/test | |
parent | fd63aa02289d64e9d14fe56723f1de64bca3bb1f (diff) | |
download | rails-9eee7822ac4bce983ad45a98c4d111eb36285199.tar.gz rails-9eee7822ac4bce983ad45a98c4d111eb36285199.tar.bz2 rails-9eee7822ac4bce983ad45a98c4d111eb36285199.zip |
Add a record to target before any callbacks loads the record
`append_record` was added at 15ddd51 for not double adding the record.
But adding `append_record` (checking `@target.include?(record)`) caused
performance regression #27434. Instead of checking not double adding the
record, add a record to target before any callbacks loads the record.
Fixes #27434.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index d657be71cc..e18b4fd12d 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -2475,7 +2475,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase test "double insertion of new object to association when same association used in the after create callback of a new object" do reset_callbacks(:save, Bulb) do - Bulb.after_save { |record| record.car.bulbs.to_a } + Bulb.after_save { |record| record.car.bulbs.load } car = Car.create! car.bulbs << Bulb.new assert_equal 1, car.bulbs.size |