From 7783b28ca27fd7cc6d25eaf261ea641ee3a43e0d Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 7 Feb 2020 17:46:42 +1100 Subject: [PATCH] Update concurrency spec after refactor In order to make the spec fail if the controller was not thread safe, it uses breakpoints. One of those breakpoints was set for a method that has now been removed. I changed the method that is used for the breakpoint and changed `allow` to `expect` so that this spec will fail if we remove that method as well. Future version of Rspec will check if a mocked method actually exists but our version just mocks it anyway. This is one way how specs can become invalid after refactoring. --- spec/controllers/checkout_controller_concurrency_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/controllers/checkout_controller_concurrency_spec.rb b/spec/controllers/checkout_controller_concurrency_spec.rb index 6a5fcd8bad..51eefe98ae 100644 --- a/spec/controllers/checkout_controller_concurrency_spec.rb +++ b/spec/controllers/checkout_controller_concurrency_spec.rb @@ -30,8 +30,11 @@ describe CheckoutController, concurrency: true, type: :controller do # New threads start running straight away. The breakpoint is after loading # the order and before advancing the order's state and making payments. breakpoint.lock - allow(controller).to receive(:check_order_for_phantom_fees) do + expect(controller).to receive(:fire_event).with("spree.checkout.update") do breakpoint.synchronize {} + # This is what fire_event does. + # I did not find out how to call the original code otherwise. + ActiveSupport::Notifications.instrument("spree.checkout.update") end end