From bdc74086e6e7224117cfb46b1f5e7540c4580485 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sun, 30 Apr 2023 00:47:15 -0400 Subject: [PATCH] Fix Rails/ContentTag cop (#24691) --- .rubocop_todo.yml | 6 ------ app/helpers/application_helper.rb | 4 ++-- app/helpers/branding_helper.rb | 4 ++-- spec/views/statuses/show.html.haml_spec.rb | 12 ++++++------ 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7a85031453a..4da60ee2400 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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: diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1981188fb18..8de89a181c4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/branding_helper.rb b/app/helpers/branding_helper.rb index 548c9541103..2b9c233c23b 100644 --- a/app/helpers/branding_helper.rb +++ b/app/helpers/branding_helper.rb @@ -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 diff --git a/spec/views/statuses/show.html.haml_spec.rb b/spec/views/statuses/show.html.haml_spec.rb index ca5bb2ae873..370743dfec3 100644 --- a/spec/views/statuses/show.html.haml_spec.rb +++ b/spec/views/statuses/show.html.haml_spec.rb @@ -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{}) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) + expect(header_tags).to match(//) + expect(header_tags).to match(//) + expect(header_tags).to match(//) + expect(header_tags).to match(%r{}) 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{}) - expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(//) end end