aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_join_model_test.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2006-03-04 15:11:17 +0000
committerJamis Buck <jamis@37signals.com>2006-03-04 15:11:17 +0000
commit964b67dd0eb2b43cc8097492c52ce777c534cd11 (patch)
treea7c9df0f71a30dff2d9e9c3b62cc39eaf4c6f7cb /activerecord/test/associations_join_model_test.rb
parentc0d24778867e8b39c160542923f4ccb6b3f48d30 (diff)
downloadrails-964b67dd0eb2b43cc8097492c52ce777c534cd11.tar.gz
rails-964b67dd0eb2b43cc8097492c52ce777c534cd11.tar.bz2
rails-964b67dd0eb2b43cc8097492c52ce777c534cd11.zip
Make counter_cache work with polymorphic belongs_to
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3756 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_join_model_test.rb')
-rw-r--r--activerecord/test/associations_join_model_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb
index f7ca3d6a84..a2f42f060e 100644
--- a/activerecord/test/associations_join_model_test.rb
+++ b/activerecord/test/associations_join_model_test.rb
@@ -104,4 +104,12 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
assert_equal [], posts(:thinking).authors
assert_equal [authors(:mary)], posts(:authorless).authors
end
+
+ def test_belongs_to_polymorphic_with_counter_cache
+ assert_equal 0, posts(:welcome)[:taggings_count]
+ tagging = posts(:welcome).taggings.create(:tag => tags(:general))
+ assert_equal 1, posts(:welcome, :reload)[:taggings_count]
+ tagging.destroy
+ assert posts(:welcome, :reload)[:taggings_count].zero?
+ end
end