From a3ade2e99c9d44577c92cdc19a60fd233781004f Mon Sep 17 00:00:00 2001 From: Paul Battley Date: Tue, 3 Jul 2012 11:59:38 +0100 Subject: Ensure jobs do not refer to the queue Jobs pushed to the queue should not contain a reference to it. As the queue itself cannot be marshalled, and as a consequence of checking the marshallability of all jobs in the test environment, we can now guarantee this to be the case in the test environment when using the default TestQueue implementation. --- railties/test/application/queue_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index e8ee8c5c9f..22d6c20404 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -109,6 +109,21 @@ module ApplicationTests end end + test "attempting to marshal a queue will raise an exception" do + app("test") + assert_raises TypeError do + Marshal.dump Rails.queue + end + end + + test "attempting to add a reference to itself to the queue will raise an exception" do + app("test") + job = {reference: Rails.queue} + assert_raises TypeError do + Rails.queue.push job + end + end + def setup_custom_queue add_to_env_config "production", <<-RUBY require "my_queue" -- cgit v1.2.3