From 3f6b013af267cea450d60c5b02ea5b87a3e39277 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Cuzik Date: Sat, 11 Nov 2023 11:04:16 -0300 Subject: [PATCH] fix: `while_executing` should not invoke conflict strategy when the job was successfully executed [v8] (#810) fix: following what #806 did to the 7.1 --- lib/sidekiq_unique_jobs/lock/while_executing.rb | 1 + spec/sidekiq_unique_jobs/lock/while_executing_spec.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/sidekiq_unique_jobs/lock/while_executing.rb b/lib/sidekiq_unique_jobs/lock/while_executing.rb index a7affb689..0aecf9a32 100644 --- a/lib/sidekiq_unique_jobs/lock/while_executing.rb +++ b/lib/sidekiq_unique_jobs/lock/while_executing.rb @@ -42,6 +42,7 @@ def execute(&block) with_logging_context do executed = locksmith.execute do yield + item[JID] ensure unlock_and_callback end diff --git a/spec/sidekiq_unique_jobs/lock/while_executing_spec.rb b/spec/sidekiq_unique_jobs/lock/while_executing_spec.rb index ba5448127..07a1d1373 100644 --- a/spec/sidekiq_unique_jobs/lock/while_executing_spec.rb +++ b/spec/sidekiq_unique_jobs/lock/while_executing_spec.rb @@ -91,10 +91,12 @@ it "reflects execution_failed" do process_one.execute do - process_two.execute { puts "BOGUS!" } - # NOTE: Below looks weird but tests that - # the result from process_two (which is nil) isn't considered. - jid_one + process_two.execute do + puts "BOGUS!" + nil + end + + nil end expect(process_one).not_to have_received(:reflect).with(:execution_failed, item_one)