未验证 提交 0133428f 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #39998 from kamipo/fix_enum_deserialize_mapping_nil

Fix deserializing enum mapping nil
......@@ -136,7 +136,6 @@ def cast(value)
end
def deserialize(value)
return if value.nil?
mapping.key(subtype.deserialize(value))
end
......
......@@ -236,6 +236,10 @@ class EnumTest < ActiveRecord::TestCase
assert_nil @book.reload.status
end
test "deserialize nil value to enum which defines nil value to hash" do
assert_equal "forgotten", books(:ddd).last_read
end
test "assign nil value" do
@book.status = nil
assert_nil @book.status
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册