diff options
author | oleg dashevskii <olegdashevskii@gmail.com> | 2010-08-25 15:52:00 +0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-30 10:17:29 -0700 |
commit | ab9622ee62e4ae6372fab69b9b148875be573a22 (patch) | |
tree | 529b905195d858ef3ce435838285c298ff8a118e /activerecord/test/cases/calculations_test.rb | |
parent | 91deff08c940f16ed149e7628694faff0393fe0a (diff) | |
download | rails-ab9622ee62e4ae6372fab69b9b148875be573a22.tar.gz rails-ab9622ee62e4ae6372fab69b9b148875be573a22.tar.bz2 rails-ab9622ee62e4ae6372fab69b9b148875be573a22.zip |
Tests proving #5441
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index afef31396e..3f963fc89a 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -275,6 +275,17 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 2, Account.count(:firm_id, :conditions => "credit_limit = 50 AND firm_id IS NOT NULL") end + def test_should_count_field_in_joined_table + assert_equal 5, Account.count('companies.id', :joins => :firm) + assert_equal 4, Account.count('companies.id', :joins => :firm, :distinct => true) + end + + def test_should_count_field_in_joined_table_with_group_by + c = Account.count('companies.id', :group => :firm_id, :joins => :firm) + + [1,6,2,9].each { |firm_id| assert c.keys.include?(firm_id) } + end + def test_count_with_no_parameters_isnt_deprecated assert_not_deprecated { Account.count } end @@ -335,5 +346,4 @@ class CalculationsTest < ActiveRecord::TestCase def test_from_option_with_table_different_than_class assert_equal Account.count(:all), Company.count(:all, :from => 'accounts') end - end |