From fe11604466fbfebc1c9e30c6296af958a4c43a01 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 3 Nov 2026 11:28:44 +0900 Subject: [PATCH 3/5] Fix error in deprecated wikitoolbar_for when the formatter has no toolbar buttons wikitoolbar_for of Redmine::WikiToolbar::Helper rendered the toolbar without checking that the text formatter defines buttons, which raised a NoMethodError for a formatter helper that includes it without them. Co-Authored-By: Claude Opus 5.5 --- lib/redmine/wiki_toolbar.rb | 2 ++ test/helpers/wiki_toolbar_helper_test.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/redmine/wiki_toolbar.rb b/lib/redmine/wiki_toolbar.rb index 6078aa1cc..b19460698 100644 --- a/lib/redmine/wiki_toolbar.rb +++ b/lib/redmine/wiki_toolbar.rb @@ -87,6 +87,8 @@ module Redmine 'wikitoolbar_for is deprecated and will be removed in Redmine 8.0. ' \ 'Please use LabelledFormBuilder#wiki_textarea or wiki_textarea_tag instead.' ) + return unless Redmine::WikiToolbar.buttons(Setting.text_formatting) + heads_for_wiki_formatter render(partial: 'wiki_toolbar/toolbar', locals: {field_id: field_id, field: nil, preview_url: preview_url, adopt_field: true}) diff --git a/test/helpers/wiki_toolbar_helper_test.rb b/test/helpers/wiki_toolbar_helper_test.rb index 1817e324a..46495ec3e 100644 --- a/test/helpers/wiki_toolbar_helper_test.rb +++ b/test/helpers/wiki_toolbar_helper_test.rb @@ -219,6 +219,15 @@ class WikiToolbarHelperTest < Redmine::HelperTest end end + def test_wikitoolbar_for_should_render_nothing_without_buttons + helper = Module.new {include Redmine::WikiToolbar::Helper} + Redmine::WikiFormatting.stubs(:helper_for).returns(helper) + + assert_deprecated(/wikitoolbar_for is deprecated/, Rails.application.deprecators[:redmine]) do + assert_nil wikitoolbar_for('issue_description') + end + end + def test_heads_for_wiki_formatter_should_only_define_image_mime_types with_settings :text_formatting => 'common_mark' do heads_for_wiki_formatter -- 2.55.0