]> source.dussan.org Git - redmine.git/commitdiff
Fix invalid "theme-*" CSS class in body element when theme name contains spaces ...
authorGo MAEDA <maeda@farend.jp>
Sat, 19 Oct 2024 08:21:18 +0000 (08:21 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 19 Oct 2024 08:21:18 +0000 (08:21 +0000)
Patch by Go MAEDA (user:maeda).

git-svn-id: https://svn.redmine.org/redmine/trunk@23144 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/integration/lib/redmine/themes_test.rb

index b116190888a6a65b5c173b23dcffaeb736a7db09..8d390d6f771937c5fb3959333a23e792c90131a8 100644 (file)
@@ -863,7 +863,7 @@ module ApplicationHelper
   def body_css_classes
     css = []
     if theme = Redmine::Themes.theme(Setting.ui_theme)
-      css << 'theme-' + theme.name
+      css << 'theme-' + theme.name.tr(' ', '_')
     end
 
     css << 'project-' + @project.identifier if @project && @project.identifier.present?
index f5fbc89b67180f4f15b994803daf9a6073587abd..42cacd172e844c6017ca3d476e8d4ee772d32231 100644 (file)
@@ -101,4 +101,12 @@ class ThemesTest < Redmine::IntegrationTest
   ensure
     Redmine::Utils.relative_url_root = ''
   end
+
+  def test_body_css_class_with_spaces_in_theme_name
+    @theme.instance_variable_set(:@name, 'Foo bar baz')
+    get '/'
+
+    assert_response :success
+    assert_select 'body[class~="theme-Foo_bar_baz"]'
+  end
 end