From 35824c7aa1a636fedd04e9ace86bcbafb2f705db Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Fri, 15 May 2020 16:57:49 +0100 Subject: [PATCH] Rename restartCheckout to order_checkout_restart to make it follow service naming convention --- app/controllers/checkout_controller.rb | 2 +- app/services/checkout/post_checkout_actions.rb | 2 +- .../{restart_checkout.rb => order_checkout_restart.rb} | 2 +- spec/controllers/checkout_controller_spec.rb | 4 ++-- spec/services/checkout/post_checkout_actions_spec.rb | 4 ++-- ...checkout_spec.rb => order_checkout_restart_spec.rb} | 10 +++++----- 6 files changed, 12 insertions(+), 12 deletions(-) rename app/services/{restart_checkout.rb => order_checkout_restart.rb} (95%) rename spec/services/{restart_checkout_spec.rb => order_checkout_restart_spec.rb} (90%) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 967f4aa8ac..2798009567 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -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 diff --git a/app/services/checkout/post_checkout_actions.rb b/app/services/checkout/post_checkout_actions.rb index f9adc32f57..f595ab0537 100644 --- a/app/services/checkout/post_checkout_actions.rb +++ b/app/services/checkout/post_checkout_actions.rb @@ -14,7 +14,7 @@ module Checkout def failure @order.updater.shipping_address_from_distributor - RestartCheckout.new(@order).call + OrderCheckoutRestart.new(@order).call end private diff --git a/app/services/restart_checkout.rb b/app/services/order_checkout_restart.rb similarity index 95% rename from app/services/restart_checkout.rb rename to app/services/order_checkout_restart.rb index 4792d070e4..6b5cb6724f 100644 --- a/app/services/restart_checkout.rb +++ b/app/services/order_checkout_restart.rb @@ -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 diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index a4adea7ba5..a07f37ff3d 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -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 diff --git a/spec/services/checkout/post_checkout_actions_spec.rb b/spec/services/checkout/post_checkout_actions_spec.rb index dfda22f4d2..916cff69fb 100644 --- a/spec/services/checkout/post_checkout_actions_spec.rb +++ b/spec/services/checkout/post_checkout_actions_spec.rb @@ -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 diff --git a/spec/services/restart_checkout_spec.rb b/spec/services/order_checkout_restart_spec.rb similarity index 90% rename from spec/services/restart_checkout_spec.rb rename to spec/services/order_checkout_restart_spec.rb index f0514c9b5f..540a6a7637 100644 --- a/spec/services/restart_checkout_spec.rb +++ b/spec/services/order_checkout_restart_spec.rb @@ -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'