diff options
author | Tom Kadwill <tomkadwill@gmail.com> | 2016-04-23 22:14:10 +0100 |
---|---|---|
committer | Tom Kadwill <tomkadwill@gmail.com> | 2016-04-28 21:22:26 +0100 |
commit | c3e3577f9d5058382504773bf0d32afa15cb131e (patch) | |
tree | 57148ba1d78773b734baf360ee6d4dbaf4b90d31 /activerecord/test/cases | |
parent | 39144740e8564a4e79e54ecfcd7a4fe8556b63e6 (diff) | |
download | rails-c3e3577f9d5058382504773bf0d32afa15cb131e.tar.gz rails-c3e3577f9d5058382504773bf0d32afa15cb131e.tar.bz2 rails-c3e3577f9d5058382504773bf0d32afa15cb131e.zip |
Fix counter_cache double increment bug
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 |