diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-10-26 19:11:19 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-10-26 19:11:19 -0700 |
commit | b79444053c6e000180c3b7787140bdb3cdafa183 (patch) | |
tree | aac77f8f73d3e204507f882015f0345c41bca033 | |
parent | bf2009f995dd8cf5cbe43908de18580d0e94e2e1 (diff) | |
download | rails-b79444053c6e000180c3b7787140bdb3cdafa183.tar.gz rails-b79444053c6e000180c3b7787140bdb3cdafa183.tar.bz2 rails-b79444053c6e000180c3b7787140bdb3cdafa183.zip |
Fix queueing tests that should be consuming the queue rather than draining it
-rw-r--r-- | activesupport/lib/active_support/queueing.rb | 2 | ||||
-rw-r--r-- | activesupport/test/queueing/threaded_consumer_test.rb | 12 |
2 files changed, 10 insertions, 4 deletions
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 |