From 4210d85a3f3ce4e980f473e9ed2becb84b58363b Mon Sep 17 00:00:00 2001 From: Jonathan Viney Date: Mon, 2 Jun 2008 15:00:15 +1200 Subject: Ensure Associations#sum returns 0 when no rows are returned. [#295 state:resolved] Signed-off-by: Pratik Naik --- activerecord/test/cases/calculations_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index a87fc26905..5cf655f7b7 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -99,6 +99,7 @@ class CalculationsTest < ActiveRecord::TestCase def test_should_return_zero_if_sum_conditions_return_nothing assert_equal 0, Account.sum(:credit_limit, :conditions => '1 = 2') + assert_equal 0, companies(:rails_core).companies.sum(:id, :conditions => '1 = 2') end def test_should_group_by_summed_field_with_conditions @@ -266,6 +267,6 @@ class CalculationsTest < ActiveRecord::TestCase end def test_should_sum_expression - assert_equal "636", Account.sum("2 * credit_limit") + assert_equal 636, Account.sum("2 * credit_limit") end end -- cgit v1.2.3