Skip to content

Commit

Permalink
Fix queueing tests that should be consuming the queue rather than dra…
Browse files Browse the repository at this point in the history
…ining it
  • Loading branch information
jeremy committed Oct 27, 2012
1 parent bf2009f commit b794440
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/queueing.rb
Expand Up @@ -83,7 +83,7 @@ def shutdown
end

def drain
run(@queue.pop) until @queue.empty?
@queue.pop.run until @queue.empty?
end

def consume
Expand Down
12 changes: 9 additions & 3 deletions activesupport/test/queueing/threaded_consumer_test.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.