From 2e2cc926271bb0906cc60f5acf2fbe06e3864919 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 3 Nov 2026 11:28:16 +0900 Subject: [PATCH 2/5] Find wiki toolbar buttons defined in modules included by a formatter helper A text formatter helper that includes the helper of a core formatter, such as Redmine::WikiFormatting::CommonMark::Helper, to reuse its toolbar got no toolbar because the buttons constant was only looked up in the helper itself. Co-Authored-By: Claude Opus 5.5 --- lib/redmine/wiki_toolbar.rb | 2 +- test/helpers/wiki_toolbar_helper_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/redmine/wiki_toolbar.rb b/lib/redmine/wiki_toolbar.rb index 0c21d0a49..6078aa1cc 100644 --- a/lib/redmine/wiki_toolbar.rb +++ b/lib/redmine/wiki_toolbar.rb @@ -56,7 +56,7 @@ module Redmine # does not use the toolbar def self.buttons(format) helper = Redmine::WikiFormatting.helper_for(format) - helper::WIKI_TOOLBAR_BUTTONS if helper.const_defined?(:WIKI_TOOLBAR_BUTTONS, false) + helper.const_get(:WIKI_TOOLBAR_BUTTONS) if helper.const_defined?(:WIKI_TOOLBAR_BUTTONS) end # Returns the names of the buttons that open a dropdown menu diff --git a/test/helpers/wiki_toolbar_helper_test.rb b/test/helpers/wiki_toolbar_helper_test.rb index 5c78b84c1..1817e324a 100644 --- a/test/helpers/wiki_toolbar_helper_test.rb +++ b/test/helpers/wiki_toolbar_helper_test.rb @@ -92,6 +92,13 @@ class WikiToolbarHelperTest < Redmine::HelperTest end end + def test_buttons_of_a_helper_including_a_core_helper + helper = Module.new {include Redmine::WikiFormatting::CommonMark::Helper} + Redmine::WikiFormatting.stubs(:helper_for).with('foo').returns(helper) + + assert_equal Redmine::WikiFormatting::CommonMark::Helper::WIKI_TOOLBAR_BUTTONS, Redmine::WikiToolbar.buttons('foo') + end + def test_buttons_should_be_translated with_settings :text_formatting => 'common_mark' do set_language_if_valid 'fr' -- 2.55.0