diff --git a/activemodel/lib/active_model/attributes.rb b/activemodel/lib/active_model/attributes.rb index 91441858f6..de94b1cf3b 100644 --- a/activemodel/lib/active_model/attributes.rb +++ b/activemodel/lib/active_model/attributes.rb @@ -115,7 +115,7 @@ module ActiveModel end def freeze - @attributes = @attributes.clone.freeze + @attributes = @attributes.clone.freeze unless frozen? super end diff --git a/activemodel/test/cases/attributes_test.rb b/activemodel/test/cases/attributes_test.rb index dd4922fe44..5e3ceda468 100644 --- a/activemodel/test/cases/attributes_test.rb +++ b/activemodel/test/cases/attributes_test.rb @@ -129,5 +129,11 @@ module ActiveModel assert data.frozen? assert_raise(FrozenError) { data.integer_field = 1 } end + + test "attributes can be frozen again" do + data = ModelForAttributesTest.new + data.freeze + assert_nothing_raised { data.freeze } + end end end