diff --git a/lib/sidekiq/middleware/server/retry_jobs.rb b/lib/sidekiq/middleware/server/retry_jobs.rb index 19185b29..611e155f 100644 --- a/lib/sidekiq/middleware/server/retry_jobs.rb +++ b/lib/sidekiq/middleware/server/retry_jobs.rb @@ -96,7 +96,7 @@ module Sidekiq def retries_exhausted(worker, msg) logger.debug { "Dropping message after hitting the retry maximum: #{msg}" } if worker.respond_to?(:retries_exhausted) - logger.warn { "Defining `retries_exhausted` as a method is deprecated, use the `sidekiq_retries_exhausted` callback instead" } + logger.warn { "Defining #{worker.class.name}#retries_exhausted as a method is deprecated, use `sidekiq_retries_exhausted` callback instead http://git.io/Ijju8g" } worker.retries_exhausted(*msg['args']) elsif worker.sidekiq_retries_exhausted_block? worker.sidekiq_retries_exhausted_block.call(*msg['args']) diff --git a/test/test_retry.rb b/test/test_retry.rb index fdd4d4f6..e09a7544 100644 --- a/test/test_retry.rb +++ b/test/test_retry.rb @@ -180,10 +180,20 @@ class TestRetry < Minitest::Test let(:msg){ {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>Time.now.utc, "retry"=>3, "retry_count"=>3} } describe "worker method" do + let(:worker) do + klass = Class.new do + include Sidekiq::Worker + + def self.name; "Worker"; end + + def retries_exhausted(*args) + args << "retried_method" + end + end + end + it 'calls worker.retries_exhausted after too many retries' do - worker.expect(:retries_exhausted, true, [1,2,"foo"]) - task_misbehaving_worker - worker.verify + assert_equal [1,2, "foo", "retried_method"], handler.retries_exhausted(worker.new, msg) end end @@ -197,7 +207,7 @@ class TestRetry < Minitest::Test end it 'calls worker sidekiq_retries_exhausted_block after too many retries' do - assert_equal [1,2, "foo", "retried"], handler.retries_exhausted(worker, msg) + assert_equal [1,2, "foo", "retried"], handler.retries_exhausted(worker.new, msg) end end