mirror of
https://github.com/github/rails.git
synced 2026-02-11 22:55:05 -05:00
Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7406 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick]
|
||||
|
||||
* Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper]
|
||||
|
||||
* Fixed that eager loading queries and with_scope should respect the :group option [DHH]
|
||||
|
||||
@@ -207,7 +207,7 @@ module ActiveRecord
|
||||
unserialized_object = object_from_yaml(@attributes[attr_name])
|
||||
|
||||
if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) || unserialized_object.nil?
|
||||
@attributes[attr_name] = unserialized_object
|
||||
@attributes.frozen? ? unserialized_object : @attributes[attr_name] = unserialized_object
|
||||
else
|
||||
raise SerializationTypeMismatch,
|
||||
"#{attr_name} was supposed to be a #{self.class.serialized_attributes[attr_name]}, but was a #{unserialized_object.class.to_s}"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require 'abstract_unit'
|
||||
require 'fixtures/topic'
|
||||
|
||||
class AttributeMethodsTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@@ -46,4 +47,12 @@ class AttributeMethodsTest < Test::Unit::TestCase
|
||||
assert_equal ['title', 1, 2, 3], topic.send(meth, 1, 2, 3)
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_unserialize_attributes_for_frozen_records
|
||||
myobj = {:value1 => :value2}
|
||||
topic = Topic.create("content" => myobj)
|
||||
topic.freeze
|
||||
assert_equal myobj, topic.content
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user