aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMariano Valles <mariano.valles@wooga.com>2014-07-16 13:20:53 +0200
committerMariano Valles <mariano.valles@wooga.com>2014-07-16 13:20:53 +0200
commita4802e217e95af14ca6ae13ab72ff3b44e2b4217 (patch)
tree1465ab68a1356a984bdd4133e10a9873c974396b /activerecord/test/cases
parentc3f4d6c8feafab9ded8b549d745c4731ee17b5c4 (diff)
downloadrails-a4802e217e95af14ca6ae13ab72ff3b44e2b4217.tar.gz
rails-a4802e217e95af14ca6ae13ab72ff3b44e2b4217.tar.bz2
rails-a4802e217e95af14ca6ae13ab72ff3b44e2b4217.zip
Fix rational to decimal on type_cast_from_user
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/types_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/types_test.rb b/activerecord/test/cases/types_test.rb
index 47cf775cb6..4ba8a3e09f 100644
--- a/activerecord/test/cases/types_test.rb
+++ b/activerecord/test/cases/types_test.rb
@@ -102,6 +102,16 @@ module ActiveRecord
assert_equal BigDecimal.new("1"), type.type_cast_from_user(:"1")
end
+ def test_type_cast_rational_to_decimal_with_precision
+ type = Type::Decimal.new(:precision => 2)
+ assert_equal BigDecimal("0.33"), type.type_cast_from_user(Rational(1, 3))
+ end
+
+ def test_type_cast_rational_to_decimal_without_precision_defaults_to_18_36
+ type = Type::Decimal.new
+ assert_equal BigDecimal("0.333333333333333333E0"), type.type_cast_from_user(Rational(1, 3))
+ end
+
def test_type_cast_binary
type = Type::Binary.new
assert_equal nil, type.type_cast_from_user(nil)