From 4d6c4f850fa80eb0702986d7a73b6a25ac1ab165 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 5 Dec 2021 12:14:37 +0000 Subject: [PATCH] Remove pointless callbacks in CheckoutController These exact same checks are already made in #load_order (and #order_invalid_for_checkout?), which is called before these other two (later) callbacks. --- app/controllers/checkout_controller.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index cd73f8ddd0..69ff2b477a 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -22,8 +22,6 @@ class CheckoutController < ::BaseController before_action :load_order - before_action :ensure_order_not_completed - before_action :ensure_checkout_allowed before_action :handle_insufficient_stock before_action :associate_user @@ -63,20 +61,12 @@ class CheckoutController < ::BaseController authorize!(:edit, current_order, session[:access_token]) end - def ensure_checkout_allowed - redirect_to main_app.cart_path unless @order.checkout_allowed? - end - - def ensure_order_not_completed - redirect_to main_app.cart_path if @order.completed? - end - def load_order @order = current_order if order_invalid_for_checkout? Bugsnag.notify("Notice: invalid order loaded during Stripe processing", order: @order) if valid_payment_intent_provided? - redirect_to(main_app.shop_path) && return + return redirect_to(main_app.shop_path) end handle_invalid_stock && return unless valid_order_line_items?