diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-04-30 22:48:50 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-04-30 22:48:50 -0600 |
commit | a4b3c78e8619ba84625ceb83118915ef36ec2cfc (patch) | |
tree | fbcc6449a23ed12deeb668959b75fa3706b12673 /activerecord/test/cases | |
parent | 0725f289e1bf70e1874de5fa7ed3312b410085f2 (diff) | |
parent | c3e3577f9d5058382504773bf0d32afa15cb131e (diff) | |
download | rails-a4b3c78e8619ba84625ceb83118915ef36ec2cfc.tar.gz rails-a4b3c78e8619ba84625ceb83118915ef36ec2cfc.tar.bz2 rails-a4b3c78e8619ba84625ceb83118915ef36ec2cfc.zip |
Merge pull request #24713 from tomkadwill/fix_counter_cache_increment
Fix counter_cache double increment bug
Close #24183
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index a3046d526e..eef70f5691 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -700,6 +700,17 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_equal 17, reply.replies.size end + def test_replace_counter_cache + topic = Topic.create(title: "Zoom-zoom-zoom") + reply = Reply.create(title: "re: zoom", content: "speedy quick!") + + reply.topic = topic + reply.save + topic.reload + + assert_equal 1, topic.replies_count + end + def test_association_assignment_sticks post = Post.first |