Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding the `jobs` method to the test queue for getting a list of test

jobs.
  • Loading branch information...
commit 0c076c00578ee58ac98108ddd8c01ac904bdaffd 1 parent 90e90d6
@tenderlove tenderlove authored
View
8 railties/lib/rails/queueing.rb
@@ -8,6 +8,14 @@ module Queueing
# Jobs are run in a separate thread to catch mistakes where code
# assumes that the job is run in the same thread.
class TestQueue < ::Queue
+ # Get a list of the jobs off this queue. This method may not be
+ # available on production queues.
+ def jobs
+ @que.dup
+ end
+
+ # Drain the queue, running all jobs in a different thread. This method
+ # may not be available on production queues.
def drain
# run the jobs in a separate thread so assumptions of synchronous
# jobs are caught in test mode.
View
6 railties/test/queueing/test_queue_test.rb
@@ -16,6 +16,12 @@ def setup
@queue = Rails::Queueing::TestQueue.new
end
+ def test_jobs
+ @queue.push 1
+ @queue.push 2
+ assert_equal [1,2], @queue.jobs
+ end
+
def test_contents
assert @queue.empty?
job = Job.new
Please sign in to comment.
Something went wrong with that request. Please try again.