• C
    Fix freeze applying to cloned objects · d5867a01
    Caleb Thompson 提交于
    Previously, freezing a cloned ActiveRecord object froze the original
    too. By cloning `@attributes` before freezing, we prevent cloned objects
    (which in Ruby share state of ivars) from being effected by `#freeze`.
    
    Resolves issue #4936, which has further information on this issue, as
    well as steps to reproduce.
    
    * Add a test case for `#freeze` not causing `cloned.frozen?` to be true.
    * Clone @attributes before freezing in `ActiveRecord::Core`, then
      reassign the cloned, frozen hash to the frozen model's `@attributes`
      ivar.
    
    /cc @steveklabnik
    d5867a01
clone_test.rb 978 字节