From 33113ba0e73004d6508fc473a6d02f91cbb35709 Mon Sep 17 00:00:00 2001 From: Paul Battley Date: Tue, 3 Jul 2012 11:55:46 +0100 Subject: 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. --- railties/lib/rails/queueing.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties/lib') 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 -- cgit v1.2.3