From b79444053c6e000180c3b7787140bdb3cdafa183 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 26 Oct 2012 19:11:19 -0700 Subject: Fix queueing tests that should be consuming the queue rather than draining it --- activesupport/lib/active_support/queueing.rb | 2 +- activesupport/test/queueing/threaded_consumer_test.rb | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/queueing.rb b/activesupport/lib/active_support/queueing.rb index 064f009f13..a89a48d057 100644 --- a/activesupport/lib/active_support/queueing.rb +++ b/activesupport/lib/active_support/queueing.rb @@ -83,7 +83,7 @@ module ActiveSupport end def drain - run(@queue.pop) until @queue.empty? + @queue.pop.run until @queue.empty? end def consume diff --git a/activesupport/test/queueing/threaded_consumer_test.rb b/activesupport/test/queueing/threaded_consumer_test.rb index 9dbb731969..a3ca46a261 100644 --- a/activesupport/test/queueing/threaded_consumer_test.rb +++ b/activesupport/test/queueing/threaded_consumer_test.rb @@ -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 -- cgit v1.2.3