aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-07-25 03:09:21 +0000
committerRick Olson <technoweenie@gmail.com>2007-07-25 03:09:21 +0000
commitd51e7f8252269492a511a9eb41f2832646a44248 (patch)
tree49854337d0b4b414171eb1ef63f8718169b211ff /activerecord/test/associations
parentb49fcde7e50c8eb378e7b1ae08f65c70f6de20e4 (diff)
downloadrails-d51e7f8252269492a511a9eb41f2832646a44248.tar.gz
rails-d51e7f8252269492a511a9eb41f2832646a44248.tar.bz2
rails-d51e7f8252269492a511a9eb41f2832646a44248.zip
Ensure that has_many :through associations use a count query instead of loading the target when #size is called. Closes #8800 [lifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7237 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations')
-rw-r--r--activerecord/test/associations/join_model_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb
index a24763b92e..d18c878733 100644
--- a/activerecord/test/associations/join_model_test.rb
+++ b/activerecord/test/associations/join_model_test.rb
@@ -451,6 +451,12 @@ class AssociationsJoinModelTest < Test::Unit::TestCase
assert_nothing_raised { vertices(:vertex_1).sinks << vertices(:vertex_5) }
end
+ def test_has_many_through_collection_size_doesnt_load_target_if_not_loaded
+ author = authors(:david)
+ assert_equal 9, author.comments.size
+ assert !author.comments.loaded?
+ end
+
def test_adding_junk_to_has_many_through_should_raise_type_mismatch
assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:thinking).tags << "Uhh what now?" }
end