Skip to content

Commit

Permalink
Deep stringify worker options to account for hash in on_conflict (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbekolay authored May 20, 2020
1 parent aee613c commit 2e79022
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def worker_method_defined?(method_sym)
def worker_options
return {} unless sidekiq_worker_class?

worker_class.get_sidekiq_options.stringify_keys
worker_class.get_sidekiq_options.deep_stringify_keys
end

# Tests that the
Expand Down
20 changes: 20 additions & 0 deletions spec/sidekiq_unique_jobs/sidekiq_worker_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,24 @@ def initialize(worker_class)
end
end
end

describe "#worker_options" do
subject(:worker_options) { worker.worker_options }

let(:worker_class) { UniqueJobOnConflictHash }

it do
expect(worker_options).to eq(
{
"lock" => :until_and_while_executing,
"on_conflict" => {
"client" => :log,
"server" => :reschedule,
},
"queue" => :customqueue,
"retry" => true,
},
)
end
end
end
15 changes: 15 additions & 0 deletions spec/support/workers/unique_job_on_conflict_hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

# :nocov:

class UniqueJobOnConflictHash
include Sidekiq::Worker

sidekiq_options lock: :until_and_while_executing,
queue: :customqueue,
on_conflict: { client: :log, server: :reschedule }

def perform(one, two)
[one, two]
end
end

0 comments on commit 2e79022

Please sign in to comment.