diff options
author | Marcelo Giorgi <marklazz.uy@gmail.com> | 2010-10-01 08:27:02 -0300 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-11 09:39:34 -0700 |
commit | 1c9022de212c190362d40b98624dcf71d20ca073 (patch) | |
tree | 526931daabb8d0de7776b32b26ddc443f0619f35 /activerecord/test/cases | |
parent | 31358d8c3c9309c3394d743bdaded29778fa060f (diff) | |
download | rails-1c9022de212c190362d40b98624dcf71d20ca073.tar.gz rails-1c9022de212c190362d40b98624dcf71d20ca073.tar.bz2 rails-1c9022de212c190362d40b98624dcf71d20ca073.zip |
Honor distinct option when used with count operation after group clause [#5721 state:resolved]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 7ec40906d4..61fbf01a50 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -346,4 +346,13 @@ class CalculationsTest < ActiveRecord::TestCase def test_from_option_with_table_different_than_class assert_equal Account.count(:all), Company.count(:all, :from => 'accounts') end + + def test_distinct_is_honored_when_used_with_count_operation_after_group + # Count the number of authors for approved topics + approved_topics_count = Topic.group(:approved).count(:author_name)[true] + assert_equal approved_topics_count, 3 + # Count the number of distinct authors for approved Topics + distinct_authors_for_approved_count = Topic.group(:approved).count(:author_name, :distinct => true)[true] + assert_equal distinct_authors_for_approved_count, 2 + end end |