aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorPaul Battley <pbattley@gmail.com>2012-07-03 11:55:46 +0100
committerPaul Battley <pbattley@gmail.com>2012-07-03 12:01:53 +0100
commit33113ba0e73004d6508fc473a6d02f91cbb35709 (patch)
tree0a66a356cb61ccd3c718a46d090c6572d9d1bbf1 /railties/lib
parent8e1d8fd0934b8e04fd6b1f8f8d4de17cd3b1abe5 (diff)
downloadrails-33113ba0e73004d6508fc473a6d02f91cbb35709.tar.gz
rails-33113ba0e73004d6508fc473a6d02f91cbb35709.tar.bz2
rails-33113ba0e73004d6508fc473a6d02f91cbb35709.zip
Ensure test jobs are marshallable
By marshalling and unmarshalling jobs when adding them to the test queue, we can ensure that jobs created during test runs are valid candidates for marshalling, and, thus, that they can be used with queueing backends other than the default simple in-process implementation. This will also be used in a subsequent commit to ensure that jobs pushed to the queue do not contain a reference to the queue itself.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/queueing.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/railties/lib/rails/queueing.rb b/railties/lib/rails/queueing.rb
index b4bc7fcd18..8a76914548 100644
--- a/railties/lib/rails/queueing.rb
+++ b/railties/lib/rails/queueing.rb
@@ -22,6 +22,13 @@ module Rails
@que.dup
end
+ # Marshal and unmarshal job before pushing it onto the queue. This will
+ # raise an exception on any attempts in tests to push jobs that can't (or
+ # shouldn't) be marshalled.
+ def push(job)
+ super Marshal.load(Marshal.dump(job))
+ end
+
# Drain the queue, running all jobs in a different thread. This method
# may not be available on production queues.
def drain