Permalink
Browse files

frozen association is no longer considered new record

  • Loading branch information...
1 parent 3d99ad9 commit 474a30a4118df521290b5a649fe04aed5a9d2e80 @ryanb committed Jul 14, 2008
Showing with 8 additions and 0 deletions.
  1. +2 −0 CHANGELOG
  2. +2 −0 lib/association_freezer/belongs_to_freezer.rb
  3. +4 −0 spec/freezer_spec.rb
View
2 CHANGELOG
@@ -1,3 +1,5 @@
+* frozen record is no longer considered new
+
* frozen record keeps id attribute of old record
* don't raise exception when trying to freeze nil association
View
2 lib/association_freezer/belongs_to_freezer.rb
@@ -32,6 +32,8 @@ def load_frozen
attributes = Marshal.load(frozen_data)
target = target_class.new(attributes.except('id'))
target.id = attributes['id']
+ target.instance_variable_set('@new_record', false)
+ target.readonly!
target.freeze
end
View
4 spec/freezer_spec.rb
@@ -97,6 +97,10 @@
it "should keep id attribute for association" do
@order.ship_method.id.should == @ship_method.id
end
+
+ it "should not consider association a new record" do
+ @order.ship_method.should_not be_new_record
+ end
end
end
end

0 comments on commit 474a30a

Please sign in to comment.