Skip to content

Commit

Permalink
Remove unused action in controller callbacks
Browse files Browse the repository at this point in the history
With Rails 7.1, callbacks only work with actions that are defined
on the controller. This check allowed us to notice we had this some
no more used actions.

This commit also enable the new configuration in the dummy app so we
will be able to spot new errors. The configuration needs to be defined
explicitely because it's not part of the load_defaults but it's copied
in the dummy application directly.
  • Loading branch information
kennyadsl committed Dec 22, 2023
1 parent b141cf8 commit b95f2dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions api/app/controllers/spree/api/payments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

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 @@ -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
4 changes: 4 additions & 0 deletions core/lib/spree/testing_support/dummy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class Application < ::Rails::Application
config.action_mailer.perform_caching = false
config.i18n.fallbacks = true

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

# In the test environment, we use the `caching: true` RSpec metadata to
# enable caching on select specs. See
# core/lib/spree/testing_support/caching.rb. See also
Expand Down

0 comments on commit b95f2dd

Please sign in to comment.