From cabec7e73ff0c7c68f7c9f31c17f6e5c516288e5 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 22 Nov 2020 17:57:01 +0000 Subject: [PATCH] Fix Rubocop warnings and tidy up --- app/controllers/concerns/order_stock_check.rb | 8 ++++---- app/controllers/spree/paypal_controller_decorator.rb | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/order_stock_check.rb b/app/controllers/concerns/order_stock_check.rb index fc2346d5e8..1578677fd4 100644 --- a/app/controllers/concerns/order_stock_check.rb +++ b/app/controllers/concerns/order_stock_check.rb @@ -4,9 +4,9 @@ module OrderStockCheck extend ActiveSupport::Concern def ensure_sufficient_stock_lines - if @order.insufficient_stock_lines.present? - flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity) - redirect_to main_app.cart_path - end + return true if @order.insufficient_stock_lines.blank? + + flash[:error] = Spree.t(:inventory_error_flash_for_insufficient_quantity) + redirect_to main_app.cart_path end end diff --git a/app/controllers/spree/paypal_controller_decorator.rb b/app/controllers/spree/paypal_controller_decorator.rb index 3324863b95..f28c75a761 100644 --- a/app/controllers/spree/paypal_controller_decorator.rb +++ b/app/controllers/spree/paypal_controller_decorator.rb @@ -60,7 +60,8 @@ Spree::PaypalController.class_eval do @order = current_order || raise(ActiveRecord::RecordNotFound) # At this point the user has come back from the Paypal form, and we get one # last chance to interact with the payment process before the money moves... - ensure_sufficient_stock_lines + return unless ensure_sufficient_stock_lines + @order.payments.create!({ source: Spree::PaypalExpressCheckout.create({ token: params[:token],