提交 77fec134 编写于 作者: J Jon Leighton

Merge pull request #10200 from calebthompson/ct-fix-freeze-freezing-cloned-models

Fix freeze applying to cloned objects
......@@ -307,9 +307,11 @@ def hash
id.hash
end
# Freeze the attributes hash such that associations are still accessible, even on destroyed records.
# Clone and freeze the attributes hash such that associations are still
# accessible, even on destroyed records, but cloned models will not be
# frozen.
def freeze
@attributes.freeze
@attributes = @attributes.clone.freeze
self
end
......
......@@ -29,5 +29,12 @@ def test_shallow
topic.author_name = 'Aaron'
assert_equal 'Aaron', cloned.author_name
end
def test_freezing_a_cloned_model_does_not_freeze_clone
cloned = Topic.new
clone = cloned.clone
cloned.freeze
assert_not clone.frozen?
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册