diff options
author | Rick Olson <technoweenie@gmail.com> | 2008-04-08 05:20:33 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2008-04-08 05:20:33 +0000 |
commit | 78c2d9fc223e7a9945aee65c838f7ce78e9ddb3e (patch) | |
tree | a1e951f726d0831a75289d29396b7f7feb34f097 /activerecord/test/cases | |
parent | 4d594cffcfc93b37fad4e423ec8593299e50133c (diff) | |
download | rails-78c2d9fc223e7a9945aee65c838f7ce78e9ddb3e.tar.gz rails-78c2d9fc223e7a9945aee65c838f7ce78e9ddb3e.tar.bz2 rails-78c2d9fc223e7a9945aee65c838f7ce78e9ddb3e.zip |
ActiveRecord::Base#sum defaults to 0 if no rows are returned. Closes #11550 [kamal]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9243 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 0ed40b469d..a87fc26905 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -97,6 +97,10 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 105, Account.sum(:credit_limit, :conditions => 'firm_id = 6') end + def test_should_return_zero_if_sum_conditions_return_nothing + assert_equal 0, Account.sum(:credit_limit, :conditions => '1 = 2') + end + def test_should_group_by_summed_field_with_conditions c = Account.sum(:credit_limit, :conditions => 'firm_id > 1', :group => :firm_id) |