diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-04-22 05:21:09 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-04-22 05:21:09 -0700 |
commit | 9b6926d317257d887480926e6df5b428f169ff7a (patch) | |
tree | 7cd4b4b2236bab3d6da3de5e3fa49265d21c63af /activerecord/test/cases | |
parent | 8758c6c6e31162b87ca6b9a43e7f2a91cc3ad2d3 (diff) | |
parent | 1e27f1c5d5d177089fbda03ba31f2f55fa622a39 (diff) | |
download | rails-9b6926d317257d887480926e6df5b428f169ff7a.tar.gz rails-9b6926d317257d887480926e6df5b428f169ff7a.tar.bz2 rails-9b6926d317257d887480926e6df5b428f169ff7a.zip |
Merge pull request #10292 from matthewrobertson/fix-update-counter-cache-on-push
Update counter cache when pushing into association
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 781b87741d..d85570236f 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -755,6 +755,15 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal topic.replies.to_a.size, topic.replies_count end + def test_pushing_association_updates_counter_cache + topic = Topic.order("id ASC").first + reply = Reply.create! + + assert_difference "topic.reload.replies_count", 1 do + topic.replies << reply + end + end + def test_deleting_updates_counter_cache_without_dependent_option post = posts(:welcome) |