Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7406

Show
Ignore:
Timestamp:
09/04/07 17:32:48 (3 years ago)
Author:
rick
Message:

Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r7380 r7406  
    11*SVN* 
     2 
     3* Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record.  [Rick] 
    24 
    35* Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper] 
  • trunk/activerecord/lib/active_record/attribute_methods.rb

    r7315 r7406  
    208208 
    209209      if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) || unserialized_object.nil? 
    210         @attributes[attr_name] = unserialized_object 
     210        @attributes.frozen? ? unserialized_object : @attributes[attr_name] = unserialized_object 
    211211      else 
    212212        raise SerializationTypeMismatch, 
  • trunk/activerecord/test/attribute_methods_test.rb

    r4635 r7406  
    11require 'abstract_unit' 
     2require 'fixtures/topic' 
    23 
    34class AttributeMethodsTest < Test::Unit::TestCase 
     
    4748    end 
    4849  end 
     50   
     51  def test_should_unserialize_attributes_for_frozen_records 
     52    myobj = {:value1 => :value2} 
     53    topic = Topic.create("content" => myobj) 
     54    topic.freeze 
     55    assert_equal myobj, topic.content 
     56     
     57  end 
    4958end