Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

frozen association is no longer considered new record

  • Loading branch information...
commit 474a30a4118df521290b5a649fe04aed5a9d2e80 1 parent 3d99ad9
Ryan Bates authored
2  CHANGELOG
... ... @@ -1,3 +1,5 @@
  1 +* frozen record is no longer considered new
  2 +
1 3 * frozen record keeps id attribute of old record
2 4
3 5 * don't raise exception when trying to freeze nil association
2  lib/association_freezer/belongs_to_freezer.rb
@@ -32,6 +32,8 @@ def load_frozen
32 32 attributes = Marshal.load(frozen_data)
33 33 target = target_class.new(attributes.except('id'))
34 34 target.id = attributes['id']
  35 + target.instance_variable_set('@new_record', false)
  36 + target.readonly!
35 37 target.freeze
36 38 end
37 39
4 spec/freezer_spec.rb
@@ -97,6 +97,10 @@
97 97 it "should keep id attribute for association" do
98 98 @order.ship_method.id.should == @ship_method.id
99 99 end
  100 +
  101 + it "should not consider association a new record" do
  102 + @order.ship_method.should_not be_new_record
  103 + end
100 104 end
101 105 end
102 106 end

0 comments on commit 474a30a

Please sign in to comment.
Something went wrong with that request. Please try again.