mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user