diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-09-30 06:47:20 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-09-30 06:47:20 +0000 |
commit | 30a652ad41428b922b1ed637f491776f1f1dff13 (patch) | |
tree | e20a92f14f88e6c5c9a46631fb1b744cb6356a3a /activerecord/test/associations | |
parent | e5a60fb2bfe0c15c297af88c19690788b00109d0 (diff) | |
download | rails-30a652ad41428b922b1ed637f491776f1f1dff13.tar.gz rails-30a652ad41428b922b1ed637f491776f1f1dff13.tar.bz2 rails-30a652ad41428b922b1ed637f491776f1f1dff13.zip |
Make size for has_many :through use counter cache if it exists. Closes #9734 [xaviershay]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7692 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations')
-rw-r--r-- | activerecord/test/associations/join_model_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb index d18c878733..d92a0c760a 100644 --- a/activerecord/test/associations/join_model_test.rb +++ b/activerecord/test/associations/join_model_test.rb @@ -457,6 +457,15 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert !author.comments.loaded? end + uses_mocha('has_many_through_collection_size_uses_counter_cache_if_it_exists') do + def test_has_many_through_collection_size_uses_counter_cache_if_it_exists + author = authors(:david) + author.stubs(:read_attribute).with('comments_count').returns(100) + assert_equal 100, author.comments.size + assert !author.comments.loaded? + end + end + def test_adding_junk_to_has_many_through_should_raise_type_mismatch assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags << "Uhh what now?" } end |