aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@oxon.ch>2013-01-23 16:28:17 +0100
committerYves Senn <yves.senn@oxon.ch>2013-01-26 12:16:28 +0100
commit648def406023b38310287588eb5efdfc739253e2 (patch)
tree120f7451a424cb8478ed14f64389bdb49ce5accf /activerecord/test/cases/calculations_test.rb
parent01341e3e432f0602891fe226ed1f2d079f590327 (diff)
downloadrails-648def406023b38310287588eb5efdfc739253e2.tar.gz
rails-648def406023b38310287588eb5efdfc739253e2.tar.bz2
rails-648def406023b38310287588eb5efdfc739253e2.zip
`#count` in conjunction with `#uniq` performs distinct count.
closes #6865
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index b7622705bf..be49e948fc 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -341,6 +341,10 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal 5, Account.count(:firm_id)
end
+ def test_count_with_uniq
+ assert_equal 4, Account.select(:credit_limit).uniq.count
+ end
+
def test_count_with_column_and_options_parameter
assert_equal 2, Account.where("credit_limit = 50 AND firm_id IS NOT NULL").count(:firm_id)
end