提交 4fd4d369 编写于 作者: M Matthew Draper 提交者: GitHub

Merge pull request #29536 from nickrivadeneira/fix-yaml

Ensure `false` is preserved in attr serialization
......@@ -122,7 +122,7 @@ def init_with(coder)
def encode_with(coder)
coder["name"] = name
coder["value_before_type_cast"] = value_before_type_cast if value_before_type_cast
coder["value_before_type_cast"] = value_before_type_cast unless value_before_type_cast.nil?
coder["type"] = type if type
coder["original_attribute"] = original_attribute if original_attribute
coder["value"] = value if defined?(@value)
......
......@@ -119,6 +119,14 @@ def test_yaml_encoding_keeps_mutations
assert_equal author.changes, dumped.changes
end
def test_yaml_encoding_keeps_false_values
topic = Topic.first
topic.approved = false
dumped = YAML.load(YAML.dump(topic))
assert_equal false, dumped.approved
end
private
def yaml_fixture(file_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册