Permalink
Browse files

Merge pull request #5268 from carlosantoniodasilva/ar-new-record-warning

Fix ActiveRecord warning in tests with Marshal
  • Loading branch information...
2 parents 2b74968 + 9b9357b commit f8f66a3792629963e91015398985cb4fad9e5900 @jonleighton jonleighton committed Mar 4, 2012
View
1 activerecord/lib/active_record/associations/association.rb
@@ -28,6 +28,7 @@ def initialize(owner, reflection)
@target = nil
@owner, @reflection = owner, reflection
@updated = false
+ @stale_state = nil
reset
reset_scope
View
1 activerecord/lib/active_record/core.rb
@@ -193,7 +193,6 @@ def init_with(coder)
@attributes = self.class.initialize_attributes(coder['attributes'])
@columns_hash = self.class.column_types.merge(coder['column_types'] || {})
-
init_internals
@new_record = false
View
9 activerecord/test/cases/base_test.rb
@@ -1944,6 +1944,15 @@ def test_marshalling_with_associations
assert_equal 1, post.comments.length
end
+ def test_marshalling_new_record_round_trip_with_associations
+ post = Post.new
+ post.comments.build
+
+ post = Marshal.load(Marshal.dump(post))
+
+ assert post.new_record?, "should be a new record"
+ end
+
def test_attribute_names
assert_equal ["id", "type", "ruby_type", "firm_id", "firm_name", "name", "client_of", "rating", "account_id"],
Company.attribute_names

0 comments on commit f8f66a3

Please sign in to comment.