Skip to content

Commit

Permalink
Fix errors that occur when unrelated tag is investigated by `Rails/…
Browse files Browse the repository at this point in the history
…ContentTag`
  • Loading branch information
r7kamura committed Oct 12, 2022
1 parent f361219 commit f34bc2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rubocop/cop/rails/content_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def allowed_argument?(argument)
argument.send_type? ||
argument.const_type? ||
argument.splat_type? ||
allowed_name?(argument)
allowed_name?(argument) ||
!argument.respond_to?(:value)
end

def register_offense(node, message, preferred_method)
Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/rails/content_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@
end
end

context 'when the first argument is keyword arguments' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
tag(factory: :tag)
RUBY
end
end

context 'when `tag` is not a top-level method (e.g. using intercom-ruby)' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
Expand Down

0 comments on commit f34bc2b

Please sign in to comment.