Skip to content

Commit

Permalink
remove deprecated unique_type (#435)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikael Henriksson <mikael@mhenrixon.com>
  • Loading branch information
zvkemp and mhenrixon authored Mar 21, 2020
1 parent 867941d commit 731996c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
12 changes: 1 addition & 11 deletions lib/sidekiq_unique_jobs/options_with_fallback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,7 @@ def lock_class
# @return [Symbol]
#
def lock_type
@lock_type ||= options[LOCK] || item[LOCK] || unique_type
end

#
# @deprecated in favour of {lock_type}
#
#
# @return [Symbol]
#
def unique_type
options[UNIQUE] || item[UNIQUE]
@lock_type ||= options[LOCK] || item[LOCK]
end

#
Expand Down
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/middleware/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
end

it "does not queue duplicates when when calling delay" do
Array.new(10) { PlainClass.delay(unique: :until_executed, queue: "customqueue").run(1) }
Array.new(10) { PlainClass.delay(lock: :until_executed, queue: "customqueue").run(1) }

expect(queue_count("customqueue")).to eq(1)
end
Expand Down
20 changes: 10 additions & 10 deletions spec/sidekiq_unique_jobs/options_with_fallback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def initialize(item, options, worker_class = nil)

it { is_expected.to eq(nil) }

context 'when options["unique"] is present' do
context 'when options["lock"] is present' do
let(:options) { { "lock" => "while_executing" } }
let(:item) { { "lock" => "until_executed" } }

Expand All @@ -57,7 +57,7 @@ def initialize(item, options, worker_class = nil)
end
end

context 'when item["unique"] is present' do
context 'when item["lock"] is present' do
let(:item) { { "lock" => "until_executed" } }

it { is_expected.to eq("until_executed") }
Expand All @@ -80,14 +80,14 @@ def initialize(item, options, worker_class = nil)

it { is_expected.to be_truthy }

context 'when options["unique"] is present' do
context 'when options["lock"] is present' do
let(:options) { { "lock" => "while_executing" } }
let(:item) { { "lock" => "until_executed" } }

it { is_expected.to be_falsey }
end

context 'when item["unique"] is present' do
context 'when item["lock"] is present' do
let(:options) { {} }
let(:item) { { "lock" => "until_executed" } }

Expand All @@ -114,12 +114,12 @@ def initialize(item, options, worker_class = nil)
describe "#lock_instance" do
subject(:lock) { options_with_fallback.lock_instance }

context 'when item["unique"] is present' do
context 'when item["lock"] is present' do
let(:unique) { :until_executed }

it { is_expected.to be_a(SidekiqUniqueJobs::Lock::UntilExecuted) }

context 'when options["unique"] is present' do
context 'when options["lock"] is present' do
let(:options) { { "lock" => :while_executing } }

it { is_expected.to be_a(SidekiqUniqueJobs::Lock::WhileExecuting) }
Expand All @@ -130,12 +130,12 @@ def initialize(item, options, worker_class = nil)
describe "#lock_class" do
subject(:lock_class) { options_with_fallback.lock_class }

context 'when item["unique"] is present' do
context 'when item["lock"] is present' do
let(:item) { { "lock" => :until_executed } }

it { is_expected.to eq(SidekiqUniqueJobs::Lock::UntilExecuted) }

context 'when options["unique"] is present' do
context 'when options["lock"] is present' do
let(:options) { { "lock" => :while_executing } }

it { is_expected.to eq(SidekiqUniqueJobs::Lock::WhileExecuting) }
Expand All @@ -156,14 +156,14 @@ def initialize(item, options, worker_class = nil)
describe "#lock_type" do
subject { options_with_fallback.lock_type }

context 'when options["unique"] is while_executing' do
context 'when options["lock"] is while_executing' do
let(:options) { { "lock" => "while_executing" } }
let(:item) { { "lock" => "until_executed" } }

it { is_expected.to eq("while_executing") }
end

context 'when item["unique"] is until_executed' do
context 'when item["lock"] is until_executed' do
let(:options) { {} }
let(:item) { { "lock" => "until_executed" } }

Expand Down

0 comments on commit 731996c

Please sign in to comment.