]> source.dussan.org Git - redmine.git/commitdiff
Fixed duplicate "disabled" class in the context_menus_helper result (#23980, #41720).
authorGo MAEDA <maeda@farend.jp>
Sun, 10 Nov 2024 06:45:26 +0000 (06:45 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 10 Nov 2024 06:45:26 +0000 (06:45 +0000)
Patch by Katsuya HIDAKA (user:hidakatsuya).

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

app/helpers/context_menus_helper.rb
test/helpers/context_menus_helper_test.rb

index bfabbbb4e187936299a24e9499d86065b4e271a6..cb8153549b34f8e6c120fac8c4996ad9ce449526 100644 (file)
 module ContextMenusHelper
   def context_menu_link(name, url, options={})
     label = name
-    options[:class] ||= ''
+    css_classes = [options[:class]]
+
     if options.delete(:selected)
-      options[:class] += ' icon disabled'
+      css_classes << 'icon disabled'
       options[:disabled] = true
       label = sprite_icon('checked', name)
     end
+
     if options.delete(:disabled)
       options.delete(:method)
       options.delete(:data)
       options[:onclick] = 'return false;'
-      options[:class] += ' disabled'
+      css_classes << 'disabled'
       url = '#'
     end
+
+    options[:class] = class_names(css_classes)
     link_to label, url, options
   end
 
index df9ea33746ba8a17680a9b0ffbf24e4d2010af69..20ad333a3d88f8a31c20588dffb88ef4575f6ac9 100644 (file)
@@ -28,7 +28,7 @@ class ContextMenusHelperTest < Redmine::HelperTest
 
     # When :selected is true
     html = context_menu_link('name', 'url', selected: true, class: 'class-a class-b')
-    assert_select_in html, 'a.class-a.class-b.icon.disabled.disabled[href=?]', '#' do
+    assert_select_in html, 'a.class-a.class-b.icon.disabled[href=?]', '#' do
       assert_select 'svg.icon-svg'
     end