aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-21 18:58:44 +0900
committerGitHub <noreply@github.com>2019-02-21 18:58:44 +0900
commitf8a798c8e60a9b288496b99b5e38e4f10d2f7c0e (patch)
treea805ca26f8b3e72681fda6918583825305c2e915 /activemodel/test
parentb57ca840a6fe64b7a76bc6585dff26e5c08879fb (diff)
parent357cd23d3aedabb99fd70b812ffcea2d1cc9893d (diff)
downloadrails-f8a798c8e60a9b288496b99b5e38e4f10d2f7c0e.tar.gz
rails-f8a798c8e60a9b288496b99b5e38e4f10d2f7c0e.tar.bz2
rails-f8a798c8e60a9b288496b99b5e38e4f10d2f7c0e.zip
Merge pull request #35336 from kamipo/dont_allow_non_numeric_string_matches_to_zero
Don't allow `where` with non numeric string matches to 0 values
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/type/integer_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activemodel/test/cases/type/integer_test.rb b/activemodel/test/cases/type/integer_test.rb
index dec188b4cc..6c02c01237 100644
--- a/activemodel/test/cases/type/integer_test.rb
+++ b/activemodel/test/cases/type/integer_test.rb
@@ -50,6 +50,14 @@ module ActiveModel
assert_equal 7200, type.cast(2.hours)
end
+ test "casting string for database" do
+ type = Type::Integer.new
+ assert_nil type.serialize("wibble")
+ assert_equal 5, type.serialize("5wibble")
+ assert_equal 5, type.serialize(" +5")
+ assert_equal(-5, type.serialize(" -5"))
+ end
+
test "casting empty string" do
type = Type::Integer.new
assert_nil type.cast("")