Permalink
Browse files

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

jobs.
  • Loading branch information...
1 parent 90e90d6 commit 0c076c00578ee58ac98108ddd8c01ac904bdaffd @tenderlove tenderlove committed Apr 27, 2012
Showing with 14 additions and 0 deletions.
  1. +8 −0 railties/lib/rails/queueing.rb
  2. +6 −0 railties/test/queueing/test_queue_test.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.
@@ -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

0 comments on commit 0c076c0

Please sign in to comment.