diff options
author | joker1007 <kakyoin.hierophant@gmail.com> | 2014-07-29 20:16:10 +0900 |
---|---|---|
committer | joker1007 <kakyoin.hierophant@gmail.com> | 2014-08-01 00:29:20 +0900 |
commit | 1d6a87779c73bc7d9d5f235afadc0df4a36f534f (patch) | |
tree | b7652dd8079e2481cd6ef9e172d41704797e6819 /activerecord/test | |
parent | 84093c662770893ad840c36f2b99204593d4a7de (diff) | |
download | rails-1d6a87779c73bc7d9d5f235afadc0df4a36f534f.tar.gz rails-1d6a87779c73bc7d9d5f235afadc0df4a36f534f.tar.bz2 rails-1d6a87779c73bc7d9d5f235afadc0df4a36f534f.zip |
Fix type casting to Decimal from Float with ...
When I defines large precision column at RDBMS,
I assigns float value, raise ArgumentError (precision too large).
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/type/decimal_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/type/decimal_test.rb b/activerecord/test/cases/type/decimal_test.rb index 951cd879dd..da30de373e 100644 --- a/activerecord/test/cases/type/decimal_test.rb +++ b/activerecord/test/cases/type/decimal_test.rb @@ -10,6 +10,11 @@ module ActiveRecord assert_equal BigDecimal.new("1"), type.type_cast_from_user(:"1") end + def test_type_cast_decimal_from_float_with_large_precision + type = Decimal.new(precision: ::Float::DIG + 2) + assert_equal BigDecimal.new("123.0"), type.type_cast_from_user(123.0) + 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)) |