diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-06-24 16:33:17 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-06-24 16:33:17 +0200 |
commit | c2b02d00ae4471ba93be4858a91741d8a7afe9c4 (patch) | |
tree | c98c18bbbe58fe6f1bfe3835e920e249aebb7190 /activerecord/test | |
parent | 1a299f1df2f97e66779f37370bcc4306843a8390 (diff) | |
parent | 50fa366783c2403d909a6fa5b7fc6d4c7fdacf7f (diff) | |
download | rails-c2b02d00ae4471ba93be4858a91741d8a7afe9c4.tar.gz rails-c2b02d00ae4471ba93be4858a91741d8a7afe9c4.tar.bz2 rails-c2b02d00ae4471ba93be4858a91741d8a7afe9c4.zip |
Merge pull request #15895 from sgrif/sg-numeric-changes
Always assume strings with non-numeric characters change numeric types
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/types_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/types_test.rb b/activerecord/test/cases/types_test.rb index 731f8cfba3..961aae88cb 100644 --- a/activerecord/test/cases/types_test.rb +++ b/activerecord/test/cases/types_test.rb @@ -79,11 +79,29 @@ module ActiveRecord assert_nil type.type_cast_from_user(1.0/0.0) end + def test_changing_integers + type = Type::Integer.new + + assert type.changed?(5, 5, '5wibble') + assert_not type.changed?(5, 5, '5') + assert_not type.changed?(5, 5, '5.0') + assert_not type.changed?(nil, nil, nil) + end + def test_type_cast_float type = Type::Float.new assert_equal 1.0, type.type_cast_from_user("1") end + def test_changing_float + type = Type::Float.new + + assert type.changed?(5.0, 5.0, '5wibble') + assert_not type.changed?(5.0, 5.0, '5') + assert_not type.changed?(5.0, 5.0, '5.0') + assert_not type.changed?(nil, nil, nil) + end + def test_type_cast_decimal type = Type::Decimal.new assert_equal BigDecimal.new("0"), type.type_cast_from_user(BigDecimal.new("0")) |