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

Fix that Sidekiq now sends instance of worker #459

Merged
merged 2 commits into from
Nov 28, 2019
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
5 changes: 2 additions & 3 deletions .reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ detectors:
- SidekiqUniqueJobs::NotUniqueWorker#initialize
- SidekiqUniqueJobs::OnConflict::Reject#push_to_deadset
- SidekiqUniqueJobs::Orphans::Reaper#entries
- SidekiqUniqueJobs::SidekiqWorkerMethods#worker_class_constantize
- SidekiqUniqueJobs::Web::Helpers#cparams
IrresponsibleModule:
enabled: true
Expand Down Expand Up @@ -113,16 +114,14 @@ detectors:
- SidekiqUniqueJobs::Locksmith#lock
- SidekiqUniqueJobs::Locksmith#lock_async
- SidekiqUniqueJobs::Locksmith#lock_sync
- SidekiqUniqueJobs::Locksmith#set_lock_info
- SidekiqUniqueJobs::Locksmith#try_lock
- SidekiqUniqueJobs::Locksmith#wait_for_primed_token
- SidekiqUniqueJobs::Logging::Middleware#logging_context
- SidekiqUniqueJobs::Middleware#call
- SidekiqUniqueJobs::Middleware#self.configure_server
- SidekiqUniqueJobs::Profiler#self.stop
- SidekiqUniqueJobs::Orphans::Manager#start
- SidekiqUniqueJobs::Orphans::Reaper#enqueued?
- SidekiqUniqueJobs::Orphans::Reaper#entries
- SidekiqUniqueJobs::SidekiqWorkerMethods#worker_class_constantize
- SidekiqUniqueJobs::Script::Caller#call_script
- SidekiqUniqueJobs::Script::Caller#extract_args
- SidekiqUniqueJobs::TimeCalculator#lock_ttl
Expand Down
3 changes: 2 additions & 1 deletion lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def after_unlock_hook
#
# @return [Sidekiq::Worker]
def worker_class_constantize(klazz = @worker_class)
return klazz unless klazz.is_a?(String)
return klazz.class if klazz.is_a?(Sidekiq::Worker) # sidekiq v6.x
return klazz unless klazz.is_a?(String)

Object.const_get(klazz)
rescue NameError => ex
Expand Down
8 changes: 7 additions & 1 deletion spec/sidekiq_unique_jobs/sidekiq_worker_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ def initialize(worker_class)
it { is_expected.to eq(MyUniqueJob) }
end

context "when worker_class is MyUniqueJob" do
context "when worker_class is instance of UntilExecutedJob" do
let(:worker_class) { UntilExecutedJob.new }

it { is_expected.to eq(UntilExecutedJob) }
end

context "when worker_class is UntilExecutedJob" do
let(:worker_class) { "UntilExecutedJob" }

it { is_expected.to eq(UntilExecutedJob) }
Expand Down