aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/counter_cache.rb
diff options
context:
space:
mode:
authorLisa Ugray <lisa.ugray@shopify.com>2017-07-12 10:22:20 -0400
committerLisa Ugray <lisa.ugray@shopify.com>2017-07-19 07:13:19 -0400
commit6137a4e8f77f0bba78d304d962b89ddf3cf465aa (patch)
tree3d4b07df17dd045ca525b6ef34d786c5244d9954 /activerecord/lib/active_record/counter_cache.rb
parenta6d6e90fa90eedbdb6d3cda679aa4b47ddfa7315 (diff)
downloadrails-6137a4e8f77f0bba78d304d962b89ddf3cf465aa.tar.gz
rails-6137a4e8f77f0bba78d304d962b89ddf3cf465aa.tar.bz2
rails-6137a4e8f77f0bba78d304d962b89ddf3cf465aa.zip
Add test for fixed `counter_cache` double increment
When an `after_create` callback did `update_attributes` on a record with multiple `belongs_to` associations with counter caches, even numbered associations would have their counters double-incremented. Fixes to `ActiveModel::Dirty` in 020abad fixed this. This adds regression tests for this bug fixed incidentally in the other commit, which also removed the need for the workaround using @_after_create_counter_called.
Diffstat (limited to 'activerecord/lib/active_record/counter_cache.rb')
-rw-r--r--activerecord/lib/active_record/counter_cache.rb1
1 files changed, 0 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index cbd71a3779..daf0eec3c2 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -180,7 +180,6 @@ module ActiveRecord
each_counter_cached_associations do |association|
if send(association.reflection.name)
association.increment_counters
- @_after_create_counter_called = true
end
end