aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/type/decimal_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/type/decimal_test.rb')
-rw-r--r--activerecord/test/cases/type/decimal_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/type/decimal_test.rb b/activerecord/test/cases/type/decimal_test.rb
index da30de373e..34ed1d7b19 100644
--- a/activerecord/test/cases/type/decimal_test.rb
+++ b/activerecord/test/cases/type/decimal_test.rb
@@ -15,6 +15,11 @@ module ActiveRecord
assert_equal BigDecimal.new("123.0"), type.type_cast_from_user(123.0)
end
+ def test_type_cast_from_float_with_unspecified_precision
+ type = Decimal.new
+ assert_equal 22.68.to_d, type.type_cast_from_user(22.68)
+ end
+
def test_type_cast_decimal_from_rational_with_precision
type = Decimal.new(precision: 2)
assert_equal BigDecimal("0.33"), type.type_cast_from_user(Rational(1, 3))
@@ -33,6 +38,14 @@ module ActiveRecord
type = Decimal.new
assert_equal BigDecimal("1"), type.type_cast_from_user(value)
end
+
+ def test_changed?
+ type = Decimal.new
+
+ assert type.changed?(5.0, 5.0, '5.0wibble')
+ assert_not type.changed?(5.0, 5.0, '5.0')
+ assert_not type.changed?(-5.0, -5.0, '-5.0')
+ end
end
end
end