diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-14 10:21:44 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-14 10:21:44 -0800 |
commit | 0b97ffd45df207ececf139352cbcc8836af89b4c (patch) | |
tree | c1a42950d1312335bed4e5d1391d2eac009b6bbf /activerecord/test | |
parent | 05e9075541f435b579a96a2519ab71ec27ace895 (diff) | |
parent | a765c8426fe39c73cf9f3ad7f8edcf588c01a11d (diff) | |
download | rails-0b97ffd45df207ececf139352cbcc8836af89b4c.tar.gz rails-0b97ffd45df207ececf139352cbcc8836af89b4c.tar.bz2 rails-0b97ffd45df207ececf139352cbcc8836af89b4c.zip |
Merge pull request #8400 from matthewrobertson/has-many-through-counter-cache
Fix for has_many_through counter_cache bug
Counter caches were not being updated properly when replacing
has_many_through relationships.
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 8e52ce1d91..2b96b42032 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -330,6 +330,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)} |