mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Rename ResetOrderService to OrderCompletionReset to follow new service naming convention and also to make it more specific to completed orders
This commit is contained in:
@@ -22,7 +22,7 @@ Spree::PaypalController.class_eval do
|
||||
if current_order.complete?
|
||||
flash[:notice] = t(:order_processed_successfully)
|
||||
|
||||
ResetOrderService.new(self, current_order).call
|
||||
OrderCompletionReset.new(self, current_order).call
|
||||
session[:access_token] = current_order.token
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module Checkout
|
||||
|
||||
def success(controller, params, current_user)
|
||||
save_order_addresses_as_user_default(params, current_user)
|
||||
ResetOrderService.new(controller, @order).call
|
||||
OrderCompletionReset.new(controller, @order).call
|
||||
end
|
||||
|
||||
def failure
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Builds a new order based on the one specified. This implements the "continue
|
||||
# shopping" feature once an order is completed.
|
||||
class ResetOrderService
|
||||
# frozen_string_literal: false
|
||||
|
||||
# Resets a completed order by building a new order based on the one specified.
|
||||
# This implements the "continue shopping" feature once an order is completed.
|
||||
class OrderCompletionReset
|
||||
# Constructor
|
||||
#
|
||||
# @param controller [#expire_current_order, #current_order]
|
||||
@@ -4,7 +4,7 @@ describe CheckoutController, type: :controller do
|
||||
let(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) }
|
||||
let(:order_cycle) { create(:simple_order_cycle) }
|
||||
let(:order) { create(:order) }
|
||||
let(:reset_order_service) { double(ResetOrderService) }
|
||||
let(:reset_order_service) { double(OrderCompletionReset) }
|
||||
|
||||
before do
|
||||
allow(order).to receive(:checkout_allowed?).and_return true
|
||||
@@ -117,8 +117,8 @@ describe CheckoutController, type: :controller do
|
||||
let(:test_shipping_method_id) { "111" }
|
||||
|
||||
before do
|
||||
# stub order and resetorderservice
|
||||
allow(ResetOrderService).to receive(:new).with(controller, order) { reset_order_service }
|
||||
# stub order and OrderCompletionReset
|
||||
allow(OrderCompletionReset).to receive(:new).with(controller, order) { reset_order_service }
|
||||
allow(reset_order_service).to receive(:call)
|
||||
allow(order).to receive(:update_attributes).and_return true
|
||||
allow(controller).to receive(:current_order).and_return order
|
||||
@@ -211,7 +211,7 @@ describe CheckoutController, type: :controller do
|
||||
end
|
||||
|
||||
it "returns order confirmation url on success" do
|
||||
allow(ResetOrderService).to receive(:new).with(controller, order) { reset_order_service }
|
||||
allow(OrderCompletionReset).to receive(:new).with(controller, order) { reset_order_service }
|
||||
expect(reset_order_service).to receive(:call)
|
||||
|
||||
allow(order).to receive(:update_attributes).and_return true
|
||||
@@ -232,7 +232,7 @@ describe CheckoutController, type: :controller do
|
||||
|
||||
describe "stale object handling" do
|
||||
it "retries when a stale object error is encountered" do
|
||||
allow(ResetOrderService).to receive(:new).with(controller, order) { reset_order_service }
|
||||
allow(OrderCompletionReset).to receive(:new).with(controller, order) { reset_order_service }
|
||||
expect(reset_order_service).to receive(:call)
|
||||
|
||||
allow(order).to receive(:update_attributes).and_return true
|
||||
|
||||
@@ -11,10 +11,10 @@ describe Checkout::PostCheckoutActions do
|
||||
let(:params) { { order: {} } }
|
||||
let(:current_user) { order.distributor.owner }
|
||||
|
||||
let(:reset_order_service) { instance_double(ResetOrderService) }
|
||||
let(:reset_order_service) { instance_double(OrderCompletionReset) }
|
||||
|
||||
before do
|
||||
expect(ResetOrderService).to receive(:new).
|
||||
expect(OrderCompletionReset).to receive(:new).
|
||||
with(controller, order).and_return(reset_order_service)
|
||||
expect(reset_order_service).to receive(:call)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe ResetOrderService do
|
||||
describe OrderCompletionReset do
|
||||
let(:current_token) { double(:current_token) }
|
||||
let(:current_distributor) { double(:distributor) }
|
||||
let(:current_order) do
|
||||
Reference in New Issue
Block a user