diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-09-01 16:00:30 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-09-01 16:02:04 -0300 |
commit | 4727a94c50e8bb371e9c9e7798a5ba0510320657 (patch) | |
tree | 84b79d9c689de09dc6e318384510c944b3ecc276 /activerecord/test/cases/type | |
parent | 9f28cb9dc778b46a3e455f9d64c719a8a95078b8 (diff) | |
download | rails-4727a94c50e8bb371e9c9e7798a5ba0510320657.tar.gz rails-4727a94c50e8bb371e9c9e7798a5ba0510320657.tar.bz2 rails-4727a94c50e8bb371e9c9e7798a5ba0510320657.zip |
Respect scale of the column in the Decimal type
[Rafael Mendonça França + Jean Boussier]
Diffstat (limited to 'activerecord/test/cases/type')
-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 fe49d0e79a..01ee36b892 100644 --- a/activerecord/test/cases/type/decimal_test.rb +++ b/activerecord/test/cases/type/decimal_test.rb @@ -25,6 +25,11 @@ module ActiveRecord assert_equal BigDecimal("0.33"), type.cast(Rational(1, 3)) end + def test_type_cast_decimal_from_rational_with_precision_and_scale + type = Decimal.new(precision: 4, scale: 2) + assert_equal BigDecimal("0.33"), type.cast(Rational(1, 3)) + end + def test_type_cast_decimal_from_rational_without_precision_defaults_to_18_36 type = Decimal.new assert_equal BigDecimal("0.333333333333333333E0"), type.cast(Rational(1, 3)) |