Fix Rubocop warnings and tidy up

This commit is contained in:
Matt-Yorkley
2020-11-22 17:57:01 +00:00
parent 87df44764f
commit cabec7e73f
2 changed files with 6 additions and 5 deletions

View File

@@ -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

View File

@@ -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],