mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Use service object directly from controller
This commit is contained in:
committed by
Rob Harrington
parent
3c73282d57
commit
bdfd718c51
@@ -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|
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user