From 0bb947e4f513f52f66379050200c643c1f419074 Mon Sep 17 00:00:00 2001 From: Bryan Tomlin Date: Tue, 16 Feb 2010 22:25:57 -0600 Subject: [PATCH] added failing test case for counter_cache not incrementing with << method --- .../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 2a77eed..ba4709c 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -306,6 +306,17 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase topic[:replies_count] = 15 assert_equal 15, topic.replies.size end + + def test_counter_cache_append + topic = Topic.create :title => "Zoom-zoom-zoom" + assert_equal 0, topic[:replies_count] + + reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") + topic.replies << reply + + assert_equal 1, topic.reload[:replies_count] + assert_equal 1, topic.replies.size + end def test_custom_counter_cache reply = Reply.create(:title => "re: zoom", :content => "speedy quick!") -- 1.6.4.2