diff options
author | Tim Macfarlane <timmacfarlane@gmail.com> | 2012-08-24 10:08:36 +0100 |
---|---|---|
committer | Tim Macfarlane <timmacfarlane@gmail.com> | 2012-10-15 22:31:05 +0100 |
commit | 51d6e21c966362ed63318d216913bcef504833a4 (patch) | |
tree | cbafbce249130e46f42b7ba590173dbe4c75403d /activerecord/test/cases/calculations_test.rb | |
parent | 081f0ad413cd821f8dad5b334e7479ffdc0b037d (diff) | |
download | rails-51d6e21c966362ed63318d216913bcef504833a4.tar.gz rails-51d6e21c966362ed63318d216913bcef504833a4.tar.bz2 rails-51d6e21c966362ed63318d216913bcef504833a4.zip |
ActiveRecord: sum expression returns string '0' for no records, fixed
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-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 6cb6c469d2..de4902f89a 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -378,6 +378,10 @@ class CalculationsTest < ActiveRecord::TestCase end end + def test_sum_expression_returns_zero_when_no_records_to_sum + assert_equal 0, Account.where('1 = 2').sum("2 * credit_limit") + end + def test_count_with_from_option assert_equal Company.count(:all), Company.from('companies').count(:all) assert_equal Account.where("credit_limit = 50").count(:all), |