Revert "Fix 9 Rubocop violations (Rails/Presence and Rails/RedirectBackOrTo)Fix rubocop violations"

This commit is contained in:
David-OFN-CA
2026-02-26 17:04:21 -05:00
committed by GitHub
parent 2d46676bb4
commit 7922bf7b65
8 changed files with 35 additions and 14 deletions

View File

@@ -177,7 +177,7 @@ module Admin
protected
def delete_custom_tab
@object.custom_tab.presence&.destroy
@object.custom_tab.destroy if @object.custom_tab.present?
enterprise_params.delete(:custom_tab_attributes)
end
@@ -240,7 +240,9 @@ module Admin
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user, @order_cycle)
.visible_enterprises
enterprises.presence&.includes(supplied_products: [:variants, :image])
if enterprises.present?
enterprises.includes(supplied_products: [:variants, :image])
end
when :index
if spree_current_user.admin?
OpenFoodNetwork::Permissions.new(spree_current_user).

View File

@@ -209,7 +209,7 @@ module Admin
elsif params[:context] == "checkout_options" && params[:save_and_back_to_list]
redirect_to main_app.admin_order_cycles_path
else
redirect_back_or_to(root_path)
redirect_back(fallback_location: root_path)
end
end

View File

@@ -3,6 +3,6 @@
class LocalesController < BaseController
def show
UserLocaleSetter.new(spree_current_user, params[:id], cookies).set_locale
redirect_back_or_to(main_app.root_url)
redirect_back fallback_location: main_app.root_url
end
end

View File

@@ -28,7 +28,7 @@ module Spree
flash[:error] = t(:must_have_valid_business_number,
enterprise_name: @order.distributor.name)
end
redirect_back_or_to(spree.admin_dashboard_path)
redirect_back(fallback_location: spree.admin_dashboard_path)
end
private

View File

@@ -80,7 +80,7 @@ module Spree
rescue Spree::Core::GatewayError => e
flash[:error] = e.message.to_s
ensure
redirect_back_or_to(spree.admin_dashboard_path)
redirect_back fallback_location: spree.admin_dashboard_path
end
def resend
@@ -88,7 +88,7 @@ module Spree
flash[:success] = t('admin.orders.order_email_resent')
respond_with(@order) do |format|
format.html { redirect_back_or_to(spree.admin_dashboard_path) }
format.html { redirect_back(fallback_location: spree.admin_dashboard_path) }
end
end

View File

@@ -10,7 +10,7 @@ module Spree
def fire
@return_authorization.public_send("#{params[:e]}!")
flash[:success] = Spree.t(:return_authorization_updated)
redirect_back_or_to(spree.admin_dashboard_path)
redirect_back fallback_location: spree.admin_dashboard_path
end
protected

View File

@@ -295,7 +295,7 @@ module Spree
# The variant is invalid if no supplier is present, but this method can be triggered when
# importing product. In this scenario the variant has not been updated with the supplier yet
# hence the check.
first_variant.supplier.presence&.touch
first_variant.supplier.touch if first_variant.supplier.present?
end
def validate_image