diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2014-04-13 12:03:54 -0400 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2014-04-13 12:03:54 -0400 |
commit | dd063f6ef436b5e6a594e70eeb50532a09ef7a57 (patch) | |
tree | e9fddfa7a5e68e630b9e4f4ca169e8c4d635c616 /activerecord/test/cases/associations | |
parent | 0bccde963c0b3e2ad65b2bdac9d144f40854ec90 (diff) | |
download | rails-dd063f6ef436b5e6a594e70eeb50532a09ef7a57.tar.gz rails-dd063f6ef436b5e6a594e70eeb50532a09ef7a57.tar.bz2 rails-dd063f6ef436b5e6a594e70eeb50532a09ef7a57.zip |
Write the failing test case for concurrent counter cache
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 21 |
1 files changed, 21 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 27f6fa575d..76a61d492a 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -502,6 +502,27 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_equal 4, topic.replies.size end + def test_concurrent_counter_cache_double_destroy + topic = Topic.create :title => "Zoom-zoom-zoom" + + 5.times do + topic.replies.create(:title => "re: zoom", :content => "speedy quick!") + end + + assert_equal 5, topic.reload[:replies_count] + assert_equal 5, topic.replies.size + + reply = topic.replies.first + reply_clone = Reply.find(reply.id) + + reply.destroy + assert_equal 4, topic.reload[:replies_count] + + reply_clone.destroy + assert_equal 4, topic.reload[:replies_count] + assert_equal 4, topic.replies.size + end + def test_custom_counter_cache reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") assert_equal 0, reply[:replies_count] |