From 9a2e164d733216b13dce7c766600b8b6ae9c9b12 Mon Sep 17 00:00:00 2001 From: kennyj Date: Tue, 22 Nov 2011 23:48:39 +0900 Subject: Added test case for new_record round trip with associations problem --- activerecord/test/cases/base_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 698c3d0cb1..190124b7aa 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1920,6 +1920,20 @@ class BasicsTest < ActiveRecord::TestCase assert_equal 1, post.comments.length end + def test_marshalling_new_record_round_trip_with_associations + if ENV['TRAVIS'] && RUBY_VERSION == "1.8.7" + return skip("Marshalling tests disabled for Ruby 1.8.7 on Travis CI due to what appears " \ + "to be a Ruby bug.") + end + + 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 -- cgit v1.2.3 From 9b9357b26eb24a55cfdcfca25bcaede72bd7902e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 4 Mar 2012 11:43:16 -0300 Subject: Initialize @stale_state to nil in association This apparently fix the warning related to @new_record variable not being initialized in AR's test suit, when an association is built and the object is marshalled/loaded. See these tests in AR's base_test.rb: test_marshalling_with_associations test_marshalling_new_record_round_trip_with_associations Closes #3720. --- activerecord/test/cases/base_test.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 190124b7aa..93f4a768d9 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1921,11 +1921,6 @@ class BasicsTest < ActiveRecord::TestCase end def test_marshalling_new_record_round_trip_with_associations - if ENV['TRAVIS'] && RUBY_VERSION == "1.8.7" - return skip("Marshalling tests disabled for Ruby 1.8.7 on Travis CI due to what appears " \ - "to be a Ruby bug.") - end - post = Post.new post.comments.build -- cgit v1.2.3