From 89b4612ffc97e6648f5cf807906ae210e05acdda Mon Sep 17 00:00:00 2001 From: Abdallah Samman Date: Mon, 3 Dec 2018 10:58:10 +0200 Subject: Fix NumericData.average test on ruby 2.6 --- activerecord/test/cases/calculations_test.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 97bce90c8b..4cb0dc66ed 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -57,8 +57,12 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 3, value end - def test_should_return_nil_as_average - assert_nil NumericData.average(:bank_balance) + def test_should_return_nil_to_d_as_average + if nil.respond_to?(:to_d) + assert_equal BigDecimal(0), NumericData.average(:bank_balance) + else + assert_nil NumericData.average(:bank_balance) + end end def test_should_get_maximum_of_field -- cgit v1.2.3