mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add edge test cases for integer and string types
This commit is contained in:
parent
78d23d820a
commit
25b3cbb241
2 changed files with 15 additions and 0 deletions
|
@ -50,6 +50,13 @@ module ActiveModel
|
|||
assert_equal 7200, type.cast(2.hours)
|
||||
end
|
||||
|
||||
test "casting empty string" do
|
||||
type = Type::Integer.new
|
||||
assert_nil type.cast("")
|
||||
assert_nil type.serialize("")
|
||||
assert_equal 0, type.deserialize("")
|
||||
end
|
||||
|
||||
test "changed?" do
|
||||
type = Type::Integer.new
|
||||
|
||||
|
|
|
@ -12,6 +12,14 @@ module ActiveModel
|
|||
assert_equal "123", type.cast(123)
|
||||
end
|
||||
|
||||
test "type casting for database" do
|
||||
type = Type::String.new
|
||||
object, array, hash = Object.new, [true], { a: :b }
|
||||
assert_equal object, type.serialize(object)
|
||||
assert_equal array, type.serialize(array)
|
||||
assert_equal hash, type.serialize(hash)
|
||||
end
|
||||
|
||||
test "cast strings are mutable" do
|
||||
type = Type::String.new
|
||||
|
||||
|
|
Loading…
Reference in a new issue