From 4531ba74938985bd2343b27d1a30d099d5975b02 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 27 Apr 2012 18:00:58 -0400 Subject: Log the exception from the ThreadConsumer This will make sure you know when there's an exception occur. --- railties/test/queueing/threaded_consumer_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'railties/test/queueing') diff --git a/railties/test/queueing/threaded_consumer_test.rb b/railties/test/queueing/threaded_consumer_test.rb index d00a67d511..8e31ebf3c7 100644 --- a/railties/test/queueing/threaded_consumer_test.rb +++ b/railties/test/queueing/threaded_consumer_test.rb @@ -62,4 +62,20 @@ class TestThreadConsumer < ActiveSupport::TestCase assert_equal true, ran end + + test "log job that raises an exception" do + require "active_support/log_subscriber/test_helper" + logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new + Rails.logger = logger + + job = Job.new(1) do + raise "RuntimeError: Error!" + end + + @queue.push job + sleep 0.1 + + assert_equal 1, logger.logged(:error).size + assert_match /Job Error: RuntimeError: Error!/, logger.logged(:error).last + end end -- cgit v1.2.3