Skip to content

Commit

Permalink
fix: pass on_failure_retry hook if retry is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
isqad committed Mar 19, 2018
1 parent eeacf88 commit 0837474
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/resque/integration/unique.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def before_dequeue_lock(*args)
end

def on_failure_retry(exception, *args)
return unless defined?(super)

# Keep meta_id if kill -9 (or ABRT)
@meta_id = args.first if exception.is_a?(::Resque::DirtyExit)

Expand Down
6 changes: 3 additions & 3 deletions spec/resque/integration/unique_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,12 @@ class JobOnlyUnique
unique

def self.execute
raise 'Some exception in Job'
raise ArgumentError.new('Some exception in Job')
end
end

let(:worker) { Resque::Worker.new(:default) }


context 'when unique with retry' do
let(:job) { Resque::Job.new(:default, 'class' => 'JobUniqueWithRetry', 'args' => ['abcd', 1, {foo: 'bar'}]) }

Expand All @@ -177,7 +176,8 @@ def self.execute
let(:job) { Resque::Job.new(:default, 'class' => 'JobOnlyUnique', 'args' => ['abcd']) }

it do
expect { job.perform }.to raise_error(RuntimeError, /no superclass method `on_failure_retry'/)
expect { job.perform }.not_to raise_error(RuntimeError, /no superclass method `on_failure_retry'/)
expect { job.perform }.to raise_error(ArgumentError)
end
end
end

0 comments on commit 0837474

Please sign in to comment.