Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep stringify worker options to account for hash in on_conflict #506

Merged
merged 1 commit into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! This test should be good enough!

},
"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