rails/rails — pull request #6445 by chancancode (2012-05-22 19:13:43+00:00)
Title: Restore the frozen state on rollback. (Backports #6420)

This is a 3-2-stable backport for #6420 which was merged into master.

Currently, when saving a frozen record, an exception would be thrown
which causes a rollback. However, there is a bug in active record that
"defrost" the record as a side effect:

>> t = Topic.new
=> #
>> t.freeze
=> #
>> t.save
RuntimeError: can't modify a frozen Hash
>> t.frozen?
=> false
>> t.save
=> true

This patch fixes the bug by explictly restoring the frozen state on the
attributes Hash after every rollback.