diff options
author | Paul Battley <pbattley@gmail.com> | 2012-07-03 11:55:46 +0100 |
---|---|---|
committer | Paul Battley <pbattley@gmail.com> | 2012-07-03 12:01:53 +0100 |
commit | 33113ba0e73004d6508fc473a6d02f91cbb35709 (patch) | |
tree | 0a66a356cb61ccd3c718a46d090c6572d9d1bbf1 /railties/lib | |
parent | 8e1d8fd0934b8e04fd6b1f8f8d4de17cd3b1abe5 (diff) | |
download | rails-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.rb | 7 |
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 |