aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-08-30 16:33:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-08-30 16:33:40 -0700
commit1b84df430c324ff90b0a180039de0a345184ec94 (patch)
treefa25fc4a0e36cf3c7bbf3b3686d42bb45695ced0 /activerecord/test/cases
parentc2be6ace40f016001043b84fe80170068eacee78 (diff)
downloadrails-1b84df430c324ff90b0a180039de0a345184ec94.tar.gz
rails-1b84df430c324ff90b0a180039de0a345184ec94.tar.bz2
rails-1b84df430c324ff90b0a180039de0a345184ec94.zip
add a failing test for marshal + cache problems
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/base_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index c91cf89f6d..9feba385a1 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1324,6 +1324,32 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal 1, post.comments.length
end
+ def test_marshal_between_processes
+ skip "fork isn't supported" unless Process.respond_to?(:fork)
+
+ # Define a new model to ensure there are no caches
+ if self.class.const_defined?("Post", false)
+ flunk "there should be no post constant"
+ end
+
+ self.class.const_set("Post", Class.new(ActiveRecord::Base) {
+ has_many :comments
+ })
+
+ rd, wr = IO.pipe
+ pid = fork do
+ rd.close
+ post = Post.new
+ post.comments.build
+ wr.write Marshal.dump(post)
+ wr.close
+ end
+
+ wr.close
+ assert Marshal.load rd.read
+ rd.close
+ end
+
def test_marshalling_new_record_round_trip_with_associations
post = Post.new
post.comments.build