Project

General

Profile

Defect #44694 » 0001-Fix-missing-Gantt-expanders-for-projects-with-only-subprojects.patch

Katsuya HIDAKA, 2026-10-30 10:12

View differences:

lib/redmine/helpers/gantt.rb
873 873
        when Version
874 874
          has_children = object.fixed_issues.exists?
875 875
        when Project
876
          has_children = object.issues.exists? || object.versions.exists?
876
          # Gantt#projects includes only projects with matching issues in their subtree,
877
          # so every project row needs an expander.
878
          has_children = true
877 879
        end
878 880
        if has_children
879 881
          content = view.content_tag(:span,
test/unit/lib/redmine/helpers/gantt_test.rb
143 143
  end
144 144
  private :setup_subjects
145 145

  
146
  # TODO: more of an integration test
147
  test "#subjects project should be rendered" do
148
    setup_subjects
149
    @output_buffer = @gantt.subjects
150
    assert_select "div.gantt-row[data-gantt-row-type=project] a", /#{@project.name}/
151
    assert_select 'div.gantt-row[data-gantt-row-type=project][style*="--gantt-row-indent:4px"]'
146
  test "#subjects should render project rows with expanders" do
147
    create_gantt
148

  
149
    # A parent with only subprojects and no issues or versions of its own.
150
    parent_project = @project
151

  
152
    # A project with an issue that is not assigned to a version.
153
    issue_project = Project.generate_with_parent!(parent_project)
154
    Issue.generate!(:project => issue_project, :fixed_version => nil)
155

  
156
    # A project with an issue assigned to its own version.
157
    version_project = Project.generate_with_parent!(parent_project)
158
    version = Version.generate!(:project => version_project)
159
    Issue.generate!(:project => version_project, :fixed_version => version)
160

  
161
    subjects = @gantt.subjects
162
    [issue_project, version_project, parent_project].each do |project|
163
      assert_select_in subjects, "div.gantt-row[data-gantt-row-key='project-#{project.id}']" do
164
        assert_select 'a[href=?]', "/projects/#{project.identifier}", :text => project.name
165
        assert_select '.expander', 1
166
      end
167
    end
168
    assert_select_in subjects, 'div.gantt-row[data-gantt-row-type=project][style*="--gantt-row-indent:4px"]'
152 169
  end
153 170

  
154 171
  test "#subjects version should be rendered" do
(3-3/3)