Permalink
Browse files

Fix queueing tests that should be consuming the queue rather than dra…

…ining it
  • Loading branch information...
1 parent bf2009f commit b79444053c6e000180c3b7787140bdb3cdafa183 @jeremy jeremy committed Oct 27, 2012
View
2 activesupport/lib/active_support/queueing.rb
@@ -83,7 +83,7 @@ def shutdown
end
def drain
- run(@queue.pop) until @queue.empty?
+ @queue.pop.run until @queue.empty?
end
def consume
View
12 activesupport/test/queueing/threaded_consumer_test.rb
@@ -65,7 +65,7 @@ def teardown
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 @@ def teardown
$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 @@ def last_error
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

0 comments on commit b794440

Please sign in to comment.