Fix Rails/ContentTag cop (#24691)

This commit is contained in:
Matt Jankowski 2023-04-30 00:47:15 -04:00 committed by GitHub
parent 6e226f5a32
commit bdc74086e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 16 deletions

View file

@ -1213,12 +1213,6 @@ Rails/CompactBlank:
- 'app/services/import_service.rb' - 'app/services/import_service.rb'
- 'config/initializers/paperclip.rb' - 'config/initializers/paperclip.rb'
# This cop supports safe autocorrection (--autocorrect).
Rails/ContentTag:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/helpers/branding_helper.rb'
# Configuration parameters: Include. # Configuration parameters: Include.
# Include: db/migrate/*.rb # Include: db/migrate/*.rb
Rails/CreateTableWithTimestamps: Rails/CreateTableWithTimestamps:

View file

@ -118,7 +118,7 @@ module ApplicationHelper
end end
def check_icon def check_icon
content_tag(:svg, tag(:path, 'fill-rule': 'evenodd', 'clip-rule': 'evenodd', d: 'M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z'), xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 20 20', fill: 'currentColor') content_tag(:svg, tag.path('fill-rule': 'evenodd', 'clip-rule': 'evenodd', d: 'M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z'), xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 20 20', fill: 'currentColor')
end end
def visibility_icon(status) def visibility_icon(status)
@ -152,7 +152,7 @@ module ApplicationHelper
end end
def opengraph(property, content) def opengraph(property, content)
tag(:meta, content: content, property: property) tag.meta(content: content, property: property)
end end
def body_classes def body_classes

View file

@ -11,11 +11,11 @@ module BrandingHelper
end end
def _logo_as_symbol_wordmark def _logo_as_symbol_wordmark
content_tag(:svg, tag(:use, href: '#logo-symbol-wordmark'), viewBox: '0 0 261 66', class: 'logo logo--wordmark') content_tag(:svg, tag.use(href: '#logo-symbol-wordmark'), viewBox: '0 0 261 66', class: 'logo logo--wordmark')
end end
def _logo_as_symbol_icon def _logo_as_symbol_icon
content_tag(:svg, tag(:use, href: '#logo-symbol-icon'), viewBox: '0 0 79 79', class: 'logo logo--icon') content_tag(:svg, tag.use(href: '#logo-symbol-icon'), viewBox: '0 0 79 79', class: 'logo logo--icon')
end end
def render_logo def render_logo

View file

@ -29,10 +29,10 @@ describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
header_tags = view.content_for(:header_tags) header_tags = view.content_for(:header_tags)
expect(header_tags).to match(%r{<meta content=".+" property="og:title" />}) expect(header_tags).to match(/<meta content=".+" property="og:title">/)
expect(header_tags).to match(%r{<meta content="article" property="og:type" />}) expect(header_tags).to match(/<meta content="article" property="og:type">/)
expect(header_tags).to match(%r{<meta content=".+" property="og:image" />}) expect(header_tags).to match(/<meta content=".+" property="og:image">/)
expect(header_tags).to match(%r{<meta content="http://.+" property="og:url" />}) expect(header_tags).to match(%r{<meta content="http://.+" property="og:url">})
end end
it 'has twitter player tag' do it 'has twitter player tag' do
@ -48,7 +48,7 @@ describe 'statuses/show.html.haml', without_verify_partial_doubles: true do
header_tags = view.content_for(:header_tags) header_tags = view.content_for(:header_tags)
expect(header_tags).to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player" />}) expect(header_tags).to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
expect(header_tags).to match(%r{<meta content="player" property="twitter:card" />}) expect(header_tags).to match(/<meta content="player" property="twitter:card">/)
end end
end end