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

remove deprecated/broken OptionsWithFallback#unique_type #435

Merged
merged 2 commits into from
Mar 21, 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
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