Remove unused actions in controller filters #5535
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What github issue is this PR for, if any?
Resolves #5502
What changed, and why?
CaseContactsController
, removed theupdate
action (which isn't defined) from theonly
list for one of the callbacksCourtDatesController
, removed thegenerate
action (which isn't defined) from theonly
list for one of the callbacksIn Rails 7.1, they've added a new configuration to catch typo'd and undefined controller actions listed in the
only
orexcept
lists to a controller filter. Relevant PR.This configuration option is written by default in
config/environments/test.rb
andconfig/environments/development.rb
. In the upgrade to Rails 7.1 in #5478, this configuration was disabled in order to pass the tests. By re-enabling it, we were able to catch a couple of places where unused actions were listed for a controller filter.We are unable to set that configuration
true
because of two lingering issues:ApplicationController
, the#verify_authorized
callback fires except for the:index
action. This is an issue becauseApplicationController
is an abstract controller -- it offers no actions of its own. One way to fix this would be to fully apply#verify_authorized
in theApplicationController
, and then, in places where this should be skipped, useskip_before_action :verify_authorized
to do so.Api::V1::BaseController
, the#authorize_user!
callback fires except for:create
. This is the same issue as above, as this is an abstract controller that doesn't have its own actions. So it could be fixed in the same way.Glad to pursue fully fixing those two remaining issues and enabling the
raise_on_missing_callback_actions
if that's desired. Or it could just be left disabled.Edit: another option would be to use option 2 specified in the following issue: ackama/rails-template#507
How will this affect user permissions?
How is this tested? (please write tests!) 💖💪
N/A
Screenshots please :)
N/A
Feelings gif (optional)
What gif best describes your feeling working on this issue? https://giphy.com/

Feedback please? (optional)
We are very interested in your feedback! Please give us some :) https://forms.gle/1D5ACNgTs2u9gSdh9