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'
- '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.
# Include: db/migrate/*.rb
Rails/CreateTableWithTimestamps:

View File

@ -118,7 +118,7 @@ module ApplicationHelper
end
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
def visibility_icon(status)
@ -152,7 +152,7 @@ module ApplicationHelper
end
def opengraph(property, content)
tag(:meta, content: content, property: property)
tag.meta(content: content, property: property)
end
def body_classes

View File

@ -11,11 +11,11 @@ module BrandingHelper
end
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
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
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)
expect(header_tags).to match(%r{<meta content=".+" property="og:title" />})
expect(header_tags).to match(%r{<meta content="article" property="og:type" />})
expect(header_tags).to match(%r{<meta content=".+" property="og:image" />})
expect(header_tags).to match(%r{<meta content="http://.+" property="og:url" />})
expect(header_tags).to match(/<meta content=".+" property="og:title">/)
expect(header_tags).to match(/<meta content="article" property="og:type">/)
expect(header_tags).to match(/<meta content=".+" property="og:image">/)
expect(header_tags).to match(%r{<meta content="http://.+" property="og:url">})
end
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)
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(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
expect(header_tags).to match(/<meta content="player" property="twitter:card">/)
end
end