Permalink
Browse files

add a failing test for marshal + cache problems

  • Loading branch information...
1 parent c2be6ac commit 1b84df430c324ff90b0a180039de0a345184ec94 @tenderlove tenderlove committed Aug 30, 2013
Showing with 26 additions and 0 deletions.
  1. +26 −0 activerecord/test/cases/base_test.rb
@@ -1324,6 +1324,32 @@ def test_marshalling_with_associations
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

0 comments on commit 1b84df4

Please sign in to comment.