mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Rename redundant #restart_checkout to #call
This commit is contained in:
@@ -18,7 +18,7 @@ class CheckoutController < Spree::CheckoutController
|
||||
# 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).restart_checkout
|
||||
RestartCheckout.new(@order).call
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -139,7 +139,7 @@ class CheckoutController < Spree::CheckoutController
|
||||
|
||||
def update_failed
|
||||
clear_ship_address
|
||||
RestartCheckout.new(@order).restart_checkout
|
||||
RestartCheckout.new(@order).call
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
|
||||
@@ -4,7 +4,7 @@ class RestartCheckout
|
||||
@order = order
|
||||
end
|
||||
|
||||
def restart_checkout
|
||||
def call
|
||||
return if order.cart?
|
||||
|
||||
reset_state_to_cart
|
||||
|
||||
@@ -189,7 +189,7 @@ describe CheckoutController, type: :controller do
|
||||
|
||||
describe "Paypal routing" do
|
||||
let(:payment_method) { create(:payment_method, type: "Spree::Gateway::PayPalExpress") }
|
||||
let(:restart_checkout) { instance_double(RestartCheckout, restart_checkout: true) }
|
||||
let(:restart_checkout) { instance_double(RestartCheckout, call: true) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:current_distributor) { distributor }
|
||||
@@ -208,9 +208,7 @@ describe CheckoutController, type: :controller do
|
||||
end
|
||||
|
||||
describe "#update_failed" do
|
||||
let(:restart_checkout) do
|
||||
instance_double(RestartCheckout, restart_checkout: true)
|
||||
end
|
||||
let(:restart_checkout) { instance_double(RestartCheckout, call: true) }
|
||||
|
||||
before do
|
||||
controller.instance_variable_set(:@order, order)
|
||||
@@ -219,7 +217,7 @@ describe CheckoutController, type: :controller do
|
||||
|
||||
it "clears the shipping address and restarts the checkout" do
|
||||
expect(controller).to receive(:clear_ship_address)
|
||||
expect(restart_checkout).to receive(:restart_checkout)
|
||||
expect(restart_checkout).to receive(:call)
|
||||
expect(controller).to receive(:respond_to)
|
||||
|
||||
controller.send(:update_failed)
|
||||
|
||||
@@ -3,11 +3,11 @@ require 'spec_helper'
|
||||
describe RestartCheckout do
|
||||
let(:order) { create(:order) }
|
||||
|
||||
describe "#restart_checkout" do
|
||||
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).restart_checkout
|
||||
RestartCheckout.new(order).call
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ describe RestartCheckout do
|
||||
# with a state other than 'pending' when the order has not been
|
||||
# completed, so this is not a case that requires testing.
|
||||
it "resets the order state, and clears incomplete shipments and payments" do
|
||||
RestartCheckout.new(order).restart_checkout
|
||||
RestartCheckout.new(order).call
|
||||
|
||||
expect(order.state).to eq 'cart'
|
||||
expect(order.shipping_method_id).to eq nil
|
||||
|
||||
Reference in New Issue
Block a user