aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-07-20 00:10:06 +0000
committerRick Olson <technoweenie@gmail.com>2007-07-20 00:10:06 +0000
commit3029a76af32113676182f902ad4f91d82c2734de (patch)
treea8d06bbeeccef27dade4955a72c901a100781add /activerecord/test
parent9014bf3f262a6b55aa4a05e2626aeebf688aa05a (diff)
downloadrails-3029a76af32113676182f902ad4f91d82c2734de.tar.gz
rails-3029a76af32113676182f902ad4f91d82c2734de.tar.bz2
rails-3029a76af32113676182f902ad4f91d82c2734de.zip
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
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations/join_model_test.rb11
1 files changed, 10 insertions, 1 deletions
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