Skip to content

Commit

Permalink
Change Rails/IgnoredSkipActionFilterOption to handle multiple callb…
Browse files Browse the repository at this point in the history
…acks
  • Loading branch information
fatkodima committed Jun 29, 2024
1 parent a6c20ed commit cc7f6b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1303](https://github.com/rubocop/rubocop-rails/pull/1303): Change `Rails/IgnoredSkipActionFilterOption` to handle multiple callbacks. ([@fatkodima][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class IgnoredSkipActionFilterOption < Base
(send
nil?
{#{FILTERS.join(' ')}}
_
...
$_)
PATTERN

Expand Down
11 changes: 11 additions & 0 deletions spec/rubocop/cop/rails/ignored_skip_action_filter_option_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
RUBY
end

it 'registers an offense for multiple actions when `if` and `only` are used together' do
expect_offense(<<~RUBY)
skip_before_action :login_required, :another_action, only: :show, if: :trusted_origin?
^^^^^^^^^^^^^^^^^^^^ `if` option will be ignored when `only` and `if` are used together.
RUBY

expect_correction(<<~RUBY)
skip_before_action :login_required, :another_action, only: :show
RUBY
end

it 'registers an offense when `if` and `except` are used together' do
expect_offense(<<~RUBY)
skip_before_action :login_required, except: :admin, if: :trusted_origin?
Expand Down

0 comments on commit cc7f6b2

Please sign in to comment.