aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-01-26 03:18:21 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-02 10:19:23 -0200
commitbf794bb36f3bd06e2e863cd6c6dfb6ceae116af2 (patch)
treea85eede4f3b73e3f05f3dbc113ae0b361f661867 /activerecord/test/cases
parent8f8ae5f03ccc30daae278c397fb88f94216b5229 (diff)
downloadrails-bf794bb36f3bd06e2e863cd6c6dfb6ceae116af2.tar.gz
rails-bf794bb36f3bd06e2e863cd6c6dfb6ceae116af2.tar.bz2
rails-bf794bb36f3bd06e2e863cd6c6dfb6ceae116af2.zip
Merge pull request #9078 from senny/6865_ar_count_with_uniq
`#count` in conjunction with `#uniq` performs distinct count. Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test/cases')
-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 d677ecb763..a1dc1de38d 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -369,6 +369,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.count(:firm_id, :conditions => "credit_limit = 50 AND firm_id IS NOT NULL")
end