diff options
author | Paul Battley <pbattley@gmail.com> | 2012-07-03 11:59:38 +0100 |
---|---|---|
committer | Paul Battley <pbattley@gmail.com> | 2012-07-03 12:01:53 +0100 |
commit | a3ade2e99c9d44577c92cdc19a60fd233781004f (patch) | |
tree | b47a94ffdc6f02d281638f29953e5a806f4e975b | |
parent | 33113ba0e73004d6508fc473a6d02f91cbb35709 (diff) | |
download | rails-a3ade2e99c9d44577c92cdc19a60fd233781004f.tar.gz rails-a3ade2e99c9d44577c92cdc19a60fd233781004f.tar.bz2 rails-a3ade2e99c9d44577c92cdc19a60fd233781004f.zip |
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.
-rw-r--r-- | railties/test/application/queue_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
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" |