Patch #41720 » 0003-Fixed-duplicate-disabled-class-in-the-context_menus_helper-result.patch
app/helpers/context_menus_helper.rb | ||
---|---|---|
20 | 20 |
module ContextMenusHelper |
21 | 21 |
def context_menu_link(name, url, options={}) |
22 | 22 |
label = name |
23 |
options[:class] ||= '' |
|
23 |
css_classes = [options[:class]] |
|
24 | ||
24 | 25 |
if options.delete(:selected) |
25 |
options[:class] += ' icon disabled'
|
|
26 |
css_classes << 'icon disabled'
|
|
26 | 27 |
options[:disabled] = true |
27 | 28 |
label = sprite_icon('checked', name) |
28 | 29 |
end |
30 | ||
29 | 31 |
if options.delete(:disabled) |
30 | 32 |
options.delete(:method) |
31 | 33 |
options.delete(:data) |
32 | 34 |
options[:onclick] = 'return false;' |
33 |
options[:class] += ' disabled'
|
|
35 |
css_classes << 'disabled'
|
|
34 | 36 |
url = '#' |
35 | 37 |
end |
38 | ||
39 |
options[:class] = class_names(css_classes) |
|
36 | 40 |
link_to label, url, options |
37 | 41 |
end |
38 | 42 |
test/helpers/context_menus_helper_test.rb | ||
---|---|---|
28 | 28 | |
29 | 29 |
# When :selected is true |
30 | 30 |
html = context_menu_link('name', 'url', selected: true, class: 'class-a class-b') |
31 |
assert_select_in html, 'a.class-a.class-b.icon.disabled.disabled[href=?]', '#' do
|
|
31 |
assert_select_in html, 'a.class-a.class-b.icon.disabled[href=?]', '#' do |
|
32 | 32 |
assert_select 'svg.icon-svg' |
33 | 33 |
end |
34 | 34 |