From 7abaaed5b63f3b66cc6b0109ae3e3390bc387fae Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 21 Mar 2025 15:45:02 +1100 Subject: [PATCH] Make test fail when we are not locking --- spec/jobs/open_order_cycle_job_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/jobs/open_order_cycle_job_spec.rb b/spec/jobs/open_order_cycle_job_spec.rb index 383d24f4d1..c1031d93d8 100644 --- a/spec/jobs/open_order_cycle_job_spec.rb +++ b/spec/jobs/open_order_cycle_job_spec.rb @@ -65,10 +65,11 @@ RSpec.describe OpenOrderCycleJob do let(:breakpoint) { Mutex.new } it "doesn't open order cycle twice" do - # Pause jobs when placing new job: + # Pause in the middle of the job to test if the second job is trying + # to do the same thing at the same time. breakpoint.lock - allow(OpenOrderCycleJob).to( - receive(:new).and_wrap_original do |method, *args| + expect_any_instance_of(OpenOrderCycleJob).to( + receive(:sync_remote_variants).and_wrap_original do |method, *args| breakpoint.synchronize {} # rubocop:disable Lint/EmptyBlock method.call(*args) end