diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-13 17:32:10 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-13 17:32:10 -0800 |
commit | d1904aff6f04bcca0ee3da4aae8477f2f30b7e85 (patch) | |
tree | 61c2b013ddf8b5eb22c59e1f5ee9c1c3dfc938fd /activerecord/test | |
parent | c0022f8d885d5cca8a7f7d3d64c60af1e04684ea (diff) | |
parent | 18ffe50581f41a4f24d791e42826c977276a0df3 (diff) | |
download | rails-d1904aff6f04bcca0ee3da4aae8477f2f30b7e85.tar.gz rails-d1904aff6f04bcca0ee3da4aae8477f2f30b7e85.tar.bz2 rails-d1904aff6f04bcca0ee3da4aae8477f2f30b7e85.zip |
Merge pull request #9278 from matthewrobertson/backport-hmt-counter-cache-bug
Backport of #8400 to fix for issue #7630, a bug in has_many :through counter caches.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 40d2e9568d..277a3bddaa 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -346,6 +346,17 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase end end + def test_update_counter_caches_on_replace_association + post = posts(:welcome) + tag = post.tags.create!(:name => 'doomed') + tag.tagged_posts << posts(:thinking) + + tag.tagged_posts = [] + post.reload + + assert_equal(post.taggings.count, post.taggings_count) + end + def test_replace_association assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)} |