Merge pull request #39998 from kamipo/fix_enum_deserialize_mapping_nil
Fix deserializing enum mapping nil
This commit is contained in:
commit
0133428ffa
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user