From 9599948fbcd67c1c2c5fecc2dca148e998479e33 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 4 Oct 2008 20:03:42 +0100 Subject: Ensure Model.sum and Model.avg typecast appropriately. [#1066 state:resolved] Model.sum delegates typecasting to the column being summed. If that's not feasible, returns a string. Model.avg always returns big decimal. --- activerecord/test/cases/calculations_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 754fd58f35..0fa61500c0 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -18,8 +18,8 @@ class CalculationsTest < ActiveRecord::TestCase def test_should_average_field value = Account.average(:credit_limit) - assert_kind_of Float, value - assert_in_delta 53.0, value, 0.001 + assert_kind_of BigDecimal, value + assert_equal BigDecimal.new('53.0'), value end def test_should_return_nil_as_average @@ -273,7 +273,7 @@ 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 def test_count_with_from_option -- cgit v1.2.3