Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused actions in controller callbacks #5566

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module SolidusAdmin
class PromotionCategoriesController < SolidusAdmin::BaseController
include SolidusAdmin::ControllerHelpers::Search

before_action :load_promotion_category, only: [:move]

def index
promotion_categories = apply_search_to(
Spree::PromotionCategory.all,
Expand All @@ -27,12 +25,5 @@ def destroy
flash[:notice] = t('.success')
redirect_back_or_to promotion_categories_path, status: :see_other
end

private

def load_promotion_category
@promotion_category = Spree::PromotionCategory.find(params[:id])
authorize! action_name, @promotion_category
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Api
class CustomerReturnsController < Spree::Api::BaseController
before_action :load_order
before_action :build_customer_return, only: [:create]
around_action :lock_order, only: [:create, :update, :destroy, :cancel]
around_action :lock_order, only: [:create, :update]

rescue_from Spree::Order::InsufficientStock, with: :insufficient_stock_error

Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/spree/api/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Spree
module Api
class PaymentsController < Spree::Api::BaseController
before_action :find_order
around_action :lock_order, only: [:create, :update, :destroy, :authorize, :capture, :purchase, :void, :credit]
before_action :find_payment, only: [:update, :show, :authorize, :purchase, :capture, :void, :credit]
around_action :lock_order, only: [:create, :update, :authorize, :capture, :purchase, :void]
before_action :find_payment, only: [:update, :show, :authorize, :purchase, :capture, :void]

def index
@payments = paginate(@order.payments.ransack(params[:q]).result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Spree
module Api
class StockMovementsController < Spree::Api::BaseController
before_action :stock_location, except: [:update, :destroy]
before_action :stock_location

def index
authorize! :index, StockMovement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AdjustmentsController < ResourceController
destroy.after :update_totals
update.after :update_totals

skip_before_action :load_resource, only: [:toggle_state, :edit, :update, :destroy]
skip_before_action :load_resource, only: [:edit, :update, :destroy]

before_action :find_adjustment, only: [:destroy, :edit, :update]

Expand Down
6 changes: 6 additions & 0 deletions core/lib/spree/testing_support/dummy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def self.setup(gem_root:, lib_name:, auto_migrate: true)

class Application < ::Rails::Application
config.load_defaults("#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}")

if Rails.gem_version >= Gem::Version.new('7.1')
config.action_controller.raise_on_missing_callback_actions = true
config.action_dispatch.show_exceptions = :none
end

# Make the test environment more production-like:
config.action_controller.allow_forgery_protection = false
config.action_controller.default_protect_from_forgery = false
Expand Down