diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-10-15 14:44:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-10-15 14:44:10 -0700 |
commit | 0a78417386958e849a32e3b8def23e3e28f1e5b0 (patch) | |
tree | cbafbce249130e46f42b7ba590173dbe4c75403d /activerecord/test | |
parent | 081f0ad413cd821f8dad5b334e7479ffdc0b037d (diff) | |
parent | 51d6e21c966362ed63318d216913bcef504833a4 (diff) | |
download | rails-0a78417386958e849a32e3b8def23e3e28f1e5b0.tar.gz rails-0a78417386958e849a32e3b8def23e3e28f1e5b0.tar.bz2 rails-0a78417386958e849a32e3b8def23e3e28f1e5b0.zip |
Merge pull request #7439 from featurist/master
ActiveRecord: sum expression returns string '0' for no records, fixed
Diffstat (limited to 'activerecord/test')
-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), |