Skip to content

Commit e160f23

Browse files
authored
Merge pull request #1304 from fatkodima/ignored_skip_action_filter_option-multiple-callbacks
Change `Rails/IgnoredSkipActionFilterOption` to handle multiple callbacks
2 parents a6c20ed + cc7f6b2 commit e160f23

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1303](https://github.com/rubocop/rubocop-rails/pull/1303): Change `Rails/IgnoredSkipActionFilterOption` to handle multiple callbacks. ([@fatkodima][])

lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class IgnoredSkipActionFilterOption < Base
5252
(send
5353
nil?
5454
{#{FILTERS.join(' ')}}
55-
_
55+
...
5656
$_)
5757
PATTERN
5858

spec/rubocop/cop/rails/ignored_skip_action_filter_option_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
RUBY
1313
end
1414

15+
it 'registers an offense for multiple actions when `if` and `only` are used together' do
16+
expect_offense(<<~RUBY)
17+
skip_before_action :login_required, :another_action, only: :show, if: :trusted_origin?
18+
^^^^^^^^^^^^^^^^^^^^ `if` option will be ignored when `only` and `if` are used together.
19+
RUBY
20+
21+
expect_correction(<<~RUBY)
22+
skip_before_action :login_required, :another_action, only: :show
23+
RUBY
24+
end
25+
1526
it 'registers an offense when `if` and `except` are used together' do
1627
expect_offense(<<~RUBY)
1728
skip_before_action :login_required, except: :admin, if: :trusted_origin?

0 commit comments

Comments
 (0)