1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix queueing tests that should be consuming the queue rather than draining it

This commit is contained in:
Jeremy Kemper 2012-10-26 19:11:19 -07:00
parent bf2009f995
commit b79444053c
2 changed files with 10 additions and 4 deletions

View file

@ -83,7 +83,7 @@ module ActiveSupport
end
def drain
run(@queue.pop) until @queue.empty?
@queue.pop.run until @queue.empty?
end
def consume

View file

@ -65,7 +65,7 @@ class TestThreadConsumer < ActiveSupport::TestCase
job = Job.new { raise "RuntimeError: Error!" }
@queue.push job
@queue.drain
consume_queue @queue
assert_equal 1, @logger.logged(:error).size
assert_match "Job Error: #{job.inspect}\nRuntimeError: Error!", @logger.logged(:error).last
@ -76,7 +76,7 @@ class TestThreadConsumer < ActiveSupport::TestCase
$stderr, old_stderr = StringIO.new, $stderr
queue = ActiveSupport::Queue.new
queue.push Job.new { raise "RuntimeError: Error!" }
queue.drain
consume_queue queue
assert_match 'Job Error', $stderr.string
ensure
$stderr = old_stderr
@ -97,8 +97,14 @@ class TestThreadConsumer < ActiveSupport::TestCase
job = Job.new { raise "RuntimeError: Error!" }
@queue.push job
@queue.drain
consume_queue @queue
assert_equal "RuntimeError: Error!", @queue.consumer.last_error
end
private
def consume_queue(queue)
queue.push nil
queue.consumer.consume
end
end