From 297ce9ef4474c80e10043db7cc61b4fc331c68c1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 15 Nov 2024 10:49:26 -0500 Subject: [PATCH] Move body class to shared partial for web app controller concern views (#31797) --- app/controllers/concerns/web_app_controller_concern.rb | 5 ----- app/views/shared/_web_app.html.haml | 1 + spec/system/about_spec.rb | 1 + spec/system/home_spec.rb | 2 ++ spec/system/privacy_spec.rb | 1 + spec/system/tags_spec.rb | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/web_app_controller_concern.rb b/app/controllers/concerns/web_app_controller_concern.rb index 9485ecda49..249bb20a25 100644 --- a/app/controllers/concerns/web_app_controller_concern.rb +++ b/app/controllers/concerns/web_app_controller_concern.rb @@ -7,7 +7,6 @@ module WebAppControllerConcern vary_by 'Accept, Accept-Language, Cookie' before_action :redirect_unauthenticated_to_permalinks! - before_action :set_app_body_class content_security_policy do |p| policy = ContentSecurityPolicy.new @@ -24,10 +23,6 @@ module WebAppControllerConcern !(ENV['ONE_CLICK_SSO_LOGIN'] == 'true' && ENV['OMNIAUTH_ONLY'] == 'true' && Devise.omniauth_providers.length == 1) && current_user.nil? end - def set_app_body_class - @body_classes = 'app-body' - end - def redirect_unauthenticated_to_permalinks! return if user_signed_in? && current_account.moved_to_account_id.nil? diff --git a/app/views/shared/_web_app.html.haml b/app/views/shared/_web_app.html.haml index 89d6ee567d..4f9a20a9f4 100644 --- a/app/views/shared/_web_app.html.haml +++ b/app/views/shared/_web_app.html.haml @@ -1,3 +1,4 @@ +- content_for :body_classes, 'app-body' - content_for :header_tags do - if user_signed_in? = preload_pack_asset 'features/compose.js' diff --git a/spec/system/about_spec.rb b/spec/system/about_spec.rb index f832802f91..d7fd7f51a1 100644 --- a/spec/system/about_spec.rb +++ b/spec/system/about_spec.rb @@ -8,5 +8,6 @@ RSpec.describe 'About page' do expect(page) .to have_css('noscript', text: /Mastodon/) + .and have_css('body', class: 'app-body') end end diff --git a/spec/system/home_spec.rb b/spec/system/home_spec.rb index c1ce4e1726..0838b3d8e7 100644 --- a/spec/system/home_spec.rb +++ b/spec/system/home_spec.rb @@ -11,6 +11,7 @@ RSpec.describe 'Home page' do expect(page) .to have_css('noscript', text: /Mastodon/) + .and have_css('body', class: 'app-body') end end @@ -20,6 +21,7 @@ RSpec.describe 'Home page' do expect(page) .to have_css('noscript', text: /Mastodon/) + .and have_css('body', class: 'app-body') end end end diff --git a/spec/system/privacy_spec.rb b/spec/system/privacy_spec.rb index 631440ebb2..f2e4d5a993 100644 --- a/spec/system/privacy_spec.rb +++ b/spec/system/privacy_spec.rb @@ -8,5 +8,6 @@ RSpec.describe 'Privacy policy page' do expect(page) .to have_css('noscript', text: /Mastodon/) + .and have_css('body', class: 'app-body') end end diff --git a/spec/system/tags_spec.rb b/spec/system/tags_spec.rb index f39c6bf0d8..9da5768c7f 100644 --- a/spec/system/tags_spec.rb +++ b/spec/system/tags_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'Tags' do expect(page) .to have_css('noscript', text: /Mastodon/) + .and have_css('body', class: 'app-body') .and have_private_cache_control end end