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

Use sidekiq/testing Worker.clear API in sidekiq_unique_jobs/testing #713

Merged
Merged
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
35 changes: 23 additions & 12 deletions lib/sidekiq_unique_jobs/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@ def use_options(tmp_config = {})

sidekiq_options(old_options)
end

#
# Clears the jobs for this worker and removes all locks
#
def clear
jobs.each do |job|
SidekiqUniqueJobs::Unlockable.unlock(job)
end

Sidekiq::Queues[queue].clear
jobs.clear
end
end

#
Expand Down Expand Up @@ -110,8 +98,31 @@ def clear_all

SidekiqUniqueJobs::Digests.new.delete_by_pattern("*", count: 10_000)
end

#
# Prepends deletion of locks to clear
#
module ClassMethods
#
# Clears the jobs for this worker and removes all locks
#
def clear
jobs.each do |job|
SidekiqUniqueJobs::Unlockable.unlock(job)
end

super
end
end
end

prepend Overrides

#
# Prepends methods to Sidekiq::Worker
#
module ClassMethods
prepend Overrides::ClassMethods
end
end
end