Skip to content

Commit

Permalink
fix: return empty string instead of nil key
Browse files Browse the repository at this point in the history
  • Loading branch information
GlauberrBatista committed Jun 23, 2023
1 parent 223897a commit 0b1c5d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resque-retry/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def retry_key_for_job(job)
if klass.respond_to?(:redis_retry_key)
klass.redis_retry_key(job['args'])
else
nil
''
end
end

Expand Down
11 changes: 11 additions & 0 deletions test/server_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@ def test_retry_key_for_job
job = Resque.delayed_timestamp_peek(timestamp, 0, 1).first
assert_equal '0', @helpers.retry_attempts_for_job(job), 'should have 0 retry attempt'
end

def test_retry_key_for_job_empty
Resque.enqueue(DelayedJobNoRetryKey)
perform_next_job(@worker)

timestamp = Resque.delayed_queue_peek(0, 1).first
job = Resque.delayed_timestamp_peek(timestamp, 0, 1).first

assert_equal '', @helpers.retry_key_for_job(job), 'should be empty string otherwise will break with redis 5'
assert_nil @helpers.retry_attempts_for_job(job), 'should have nil retry attempts as the key does not exist'
end
end
4 changes: 4 additions & 0 deletions test/test_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ class LimitThreeJobDelay1Hour < LimitThreeJob
@retry_delay = 3600
end

class DelayedJobNoRetryKey
@queue = :testing
end

class FailFiveTimesJob < RetryDefaultsJob
@queue = :testing
@retry_limit = 6
Expand Down

0 comments on commit 0b1c5d1

Please sign in to comment.