diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-08-04 13:09:13 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-08-04 13:09:13 +0200 |
commit | b2e88043b52a8f83820a0f4e8a65aa42fd40c544 (patch) | |
tree | ae1d5d749e2f38e7e56d6b4c50b238cdd59846cb /activerecord/test/cases | |
parent | 3d70f0740b26b0a137d7e6436f9909330f8ee888 (diff) | |
parent | 1d6a87779c73bc7d9d5f235afadc0df4a36f534f (diff) | |
download | rails-b2e88043b52a8f83820a0f4e8a65aa42fd40c544.tar.gz rails-b2e88043b52a8f83820a0f4e8a65aa42fd40c544.tar.bz2 rails-b2e88043b52a8f83820a0f4e8a65aa42fd40c544.zip |
Merge pull request #16333 from joker1007/fix_decimal_cast_from_float_with_large_precision
Fix type casting to Decimal from Float with large precision
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test/cases')
-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)) |