mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
Rename restartCheckout to order_checkout_restart to make it follow service naming convention
This commit is contained in:
@@ -40,7 +40,7 @@ class CheckoutController < Spree::StoreController
|
||||
# This is only required because of spree_paypal_express. If we implement
|
||||
# a version of paypal that uses this controller, and more specifically
|
||||
# the #update_failed method, then we can remove this call
|
||||
RestartCheckout.new(@order).call
|
||||
OrderCheckoutRestart.new(@order).call
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -14,7 +14,7 @@ module Checkout
|
||||
|
||||
def failure
|
||||
@order.updater.shipping_address_from_distributor
|
||||
RestartCheckout.new(@order).call
|
||||
OrderCheckoutRestart.new(@order).call
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Resets the passed order to cart state while clearing associated payments and shipments
|
||||
class RestartCheckout
|
||||
class OrderCheckoutRestart
|
||||
def initialize(order)
|
||||
@order = order
|
||||
end
|
||||
@@ -299,11 +299,11 @@ describe CheckoutController, type: :controller do
|
||||
end
|
||||
|
||||
describe "#update_failed" do
|
||||
let(:restart_checkout) { instance_double(RestartCheckout, call: true) }
|
||||
let(:restart_checkout) { instance_double(OrderCheckoutRestart, call: true) }
|
||||
|
||||
before do
|
||||
controller.instance_variable_set(:@order, order)
|
||||
allow(RestartCheckout).to receive(:new) { restart_checkout }
|
||||
allow(OrderCheckoutRestart).to receive(:new) { restart_checkout }
|
||||
allow(controller).to receive(:current_order) { order }
|
||||
end
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ describe Checkout::PostCheckoutActions do
|
||||
end
|
||||
|
||||
describe "#failure" do
|
||||
let(:restart_checkout_service) { instance_double(RestartCheckout) }
|
||||
let(:restart_checkout_service) { instance_double(OrderCheckoutRestart) }
|
||||
|
||||
it "restarts the checkout process" do
|
||||
expect(RestartCheckout).to receive(:new).with(order).and_return(restart_checkout_service)
|
||||
expect(OrderCheckoutRestart).to receive(:new).with(order).and_return(restart_checkout_service)
|
||||
expect(restart_checkout_service).to receive(:call)
|
||||
|
||||
postCheckoutActions.failure
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe RestartCheckout do
|
||||
describe OrderCheckoutRestart do
|
||||
let(:order) { create(:order_with_distributor) }
|
||||
|
||||
describe "#call" do
|
||||
context "when the order is already in the 'cart' state" do
|
||||
it "does nothing" do
|
||||
expect(order).to_not receive(:restart_checkout!)
|
||||
RestartCheckout.new(order).call
|
||||
OrderCheckoutRestart.new(order).call
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ describe RestartCheckout do
|
||||
before { order.ship_address = nil }
|
||||
|
||||
it "resets the order state, and clears incomplete shipments and payments" do
|
||||
RestartCheckout.new(order).call
|
||||
OrderCheckoutRestart.new(order).call
|
||||
|
||||
expect_cart_state_and_reset_adjustments
|
||||
end
|
||||
@@ -35,7 +35,7 @@ describe RestartCheckout do
|
||||
before { order.ship_address = order.address_from_distributor }
|
||||
|
||||
it "resets the order state, and clears incomplete shipments and payments" do
|
||||
RestartCheckout.new(order).call
|
||||
OrderCheckoutRestart.new(order).call
|
||||
|
||||
expect_cart_state_and_reset_adjustments
|
||||
end
|
||||
@@ -46,7 +46,7 @@ describe RestartCheckout do
|
||||
|
||||
it "does not reset the order state nor clears incomplete shipments and payments" do
|
||||
expect do
|
||||
RestartCheckout.new(order).call
|
||||
OrderCheckoutRestart.new(order).call
|
||||
end.to raise_error(StateMachine::InvalidTransition)
|
||||
|
||||
expect(order.state).to eq 'payment'
|
||||
Reference in New Issue
Block a user