From 3029a76af32113676182f902ad4f91d82c2734de Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Fri, 20 Jul 2007 00:10:06 +0000 Subject: Fix #count on a has_many :through association so that it recognizes the :uniq option. Closes #8801 [lifofifo] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7199 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/associations/join_model_test.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'activerecord/test') diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb index a784a8eefd..a24763b92e 100644 --- a/activerecord/test/associations/join_model_test.rb +++ b/activerecord/test/associations/join_model_test.rb @@ -30,7 +30,16 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_equal 2, authors(:mary).categorized_posts.size assert_equal 1, authors(:mary).unique_categorized_posts.size end - + + def test_has_many_uniq_through_count + author = authors(:mary) + assert !authors(:mary).unique_categorized_posts.loaded? + assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count } + assert_queries(1) { assert_equal 1, author.unique_categorized_posts.count(:title) } + assert_queries(1) { assert_equal 0, author.unique_categorized_posts.count(:title, :conditions => "title is NULL") } + assert !authors(:mary).unique_categorized_posts.loaded? + end + def test_polymorphic_has_many assert posts(:welcome).taggings.include?(taggings(:welcome_general)) end -- cgit v1.2.3