From 6137a4e8f77f0bba78d304d962b89ddf3cf465aa Mon Sep 17 00:00:00 2001 From: Lisa Ugray Date: Wed, 12 Jul 2017 10:22:20 -0400 Subject: 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. --- activerecord/test/models/comment.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test/models/comment.rb') diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index dc2d421cd7..6eff268dd6 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -75,3 +75,9 @@ class CommentWithDefaultScopeReferencesAssociation < Comment default_scope -> { includes(:developer).order("developers.name").references(:developer) } belongs_to :developer end + +class CommentWithAfterCreateUpdate < Comment + after_create do + update_attributes(body: "bar") + end +end -- cgit v1.2.3