diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-03-04 10:34:34 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-03-04 10:34:34 -0800 |
commit | f8f66a3792629963e91015398985cb4fad9e5900 (patch) | |
tree | 4212e31725bf12e6eae37441aed21d076e938959 /activerecord | |
parent | 2b74968f03fa4fbdf8afaa497b8446cb00fbddcd (diff) | |
parent | 9b9357b26eb24a55cfdcfca25bcaede72bd7902e (diff) | |
download | rails-f8f66a3792629963e91015398985cb4fad9e5900.tar.gz rails-f8f66a3792629963e91015398985cb4fad9e5900.tar.bz2 rails-f8f66a3792629963e91015398985cb4fad9e5900.zip |
Merge pull request #5268 from carlosantoniodasilva/ar-new-record-warning
Fix ActiveRecord warning in tests with Marshal
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/association.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/core.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 9 |
3 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 7887d59aad..c971fbb393 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -28,6 +28,7 @@ module ActiveRecord @target = nil @owner, @reflection = owner, reflection @updated = false + @stale_state = nil reset reset_scope diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 3f90d25962..e75a2a1cb4 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -193,7 +193,6 @@ module ActiveRecord @attributes = self.class.initialize_attributes(coder['attributes']) @columns_hash = self.class.column_types.merge(coder['column_types'] || {}) - init_internals @new_record = false diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 444ea474b1..01f647b261 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1944,6 +1944,15 @@ class BasicsTest < ActiveRecord::TestCase 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 |