Refactor load_order to fix rubocop issues

This commit is contained in:
luisramos0
2020-02-04 13:10:51 +00:00
parent 25431f851b
commit 06569ea24c

View File

@@ -224,13 +224,19 @@ class CheckoutController < Spree::StoreController
def load_order
@order = current_order
redirect_to(main_app.shop_path) && return unless @order && @order.checkout_allowed?
redirect_to(main_app.shop_path) && return if redirect_to_shop?
redirect_to_cart_path && return unless valid_order_line_items?
redirect_to(main_app.shop_path) && return if @order.completed?
before_address
setup_for_current_state
end
def redirect_to_shop?
!@order ||
!@order.checkout_allowed? ||
@order.completed?
end
def setup_for_current_state
method_name = :"before_#{@order.state}"
__send__(method_name) if respond_to?(method_name, true)