diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 15d4058909..c21a9def25 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -40,7 +40,7 @@ class CheckoutController < Spree::CheckoutController set_default_bill_address set_default_ship_address - reset_order + ResetOrderService.new(self).call flash[:success] = t(:order_processed_successfully) respond_to do |format| diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index c4f770cb6c..f7775ba931 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -4,6 +4,8 @@ describe CheckoutController do let(:distributor) { double(:distributor) } let(:order_cycle) { create(:simple_order_cycle) } let(:order) { create(:order) } + let(:reset_order_service) { double(ResetOrderService) } + before do order.stub(:checkout_allowed?).and_return true controller.stub(:check_authorization).and_return true @@ -106,7 +108,8 @@ describe CheckoutController do end it "returns order confirmation url on success" do - expect(controller).to receive(:reset_order) + allow(ResetOrderService).to receive(:new).with(controller) { reset_order_service } + expect(reset_order_service).to receive(:call) order.stub(:update_attributes).and_return true order.stub(:state).and_return "complete" @@ -118,7 +121,8 @@ describe CheckoutController do describe "stale object handling" do it "retries when a stale object error is encountered" do - expect(controller).to receive(:reset_order) + allow(ResetOrderService).to receive(:new).with(controller) { reset_order_service } + expect(reset_order_service).to receive(:call) order.stub(:update_attributes).and_return true controller.stub(:state_callback)