From 7778c155074d36db36fee8324e1a12e36f91f198 Mon Sep 17 00:00:00 2001 From: Katsuya HIDAKA Date: Sun, 18 Oct 2026 15:50:03 +0900 Subject: Fix missing Gantt expanders for projects with only subprojects --- lib/redmine/helpers/gantt.rb | 4 ++- test/unit/lib/redmine/helpers/gantt_test.rb | 29 ++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 21a6c5fa2..e3747761a 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -873,7 +873,9 @@ module Redmine when Version has_children = object.fixed_issues.exists? when Project - has_children = object.issues.exists? || object.versions.exists? + # Gantt#projects includes only projects with matching issues in their subtree, + # so every project row needs an expander. + has_children = true end if has_children content = view.content_tag(:span, diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index 0915f6883..591a65788 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -143,12 +143,29 @@ class Redmine::Helpers::GanttHelperTest < Redmine::HelperTest end private :setup_subjects - # TODO: more of an integration test - test "#subjects project should be rendered" do - setup_subjects - @output_buffer = @gantt.subjects - assert_select "div.gantt-row[data-gantt-row-type=project] a", /#{@project.name}/ - assert_select 'div.gantt-row[data-gantt-row-type=project][style*="--gantt-row-indent:4px"]' + test "#subjects should render project rows with expanders" do + create_gantt + + # A parent with only subprojects and no issues or versions of its own. + parent_project = @project + + # A project with an issue that is not assigned to a version. + issue_project = Project.generate_with_parent!(parent_project) + Issue.generate!(:project => issue_project, :fixed_version => nil) + + # A project with an issue assigned to its own version. + version_project = Project.generate_with_parent!(parent_project) + version = Version.generate!(:project => version_project) + Issue.generate!(:project => version_project, :fixed_version => version) + + subjects = @gantt.subjects + [issue_project, version_project, parent_project].each do |project| + assert_select_in subjects, "div.gantt-row[data-gantt-row-key='project-#{project.id}']" do + assert_select 'a[href=?]', "/projects/#{project.identifier}", :text => project.name + assert_select '.expander', 1 + end + end + assert_select_in subjects, 'div.gantt-row[data-gantt-row-type=project][style*="--gantt-row-indent:4px"]' end test "#subjects version should be rendered" do -- 2.51.0