Skip to content

Commit

Permalink
adding the jobs method to the test queue for getting a list of test
Browse files Browse the repository at this point in the history
jobs.
  • Loading branch information
tenderlove committed Apr 27, 2012
1 parent 90e90d6 commit 0c076c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions railties/lib/rails/queueing.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ module Queueing
# Jobs are run in a separate thread to catch mistakes where code # Jobs are run in a separate thread to catch mistakes where code
# assumes that the job is run in the same thread. # assumes that the job is run in the same thread.
class TestQueue < ::Queue 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 def drain
# run the jobs in a separate thread so assumptions of synchronous # run the jobs in a separate thread so assumptions of synchronous
# jobs are caught in test mode. # jobs are caught in test mode.
Expand Down
6 changes: 6 additions & 0 deletions railties/test/queueing/test_queue_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def setup
@queue = Rails::Queueing::TestQueue.new @queue = Rails::Queueing::TestQueue.new
end end


def test_jobs
@queue.push 1
@queue.push 2
assert_equal [1,2], @queue.jobs
end

def test_contents def test_contents
assert @queue.empty? assert @queue.empty?
job = Job.new job = Job.new
Expand Down

0 comments on commit 0c076c0

Please sign in to comment.