From 89f60e6e2f728ebe73ca8baa070beba7c680ef9f Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 20 Jun 2021 09:31:36 +0300 Subject: [PATCH] Link to global time entries if issue has subtasks and subtasks can be on projects that are not descendants of the current project --- app/helpers/issues_helper.rb | 5 +++++ test/helpers/issues_helper_test.rb | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 756d7ed4c..b8e1dd414 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -264,6 +264,11 @@ module IssuesHelper if issue.total_spent_hours == issue.spent_hours link_to(l_hours_short(issue.spent_hours), path) else + # link to global time entries if cross-project subtasks are allowed + # in order to show time entries from not descendents projects + if %w(system tree hierarchy).include?(Setting.cross_project_subtasks) + path = time_entries_path(:issue_id => "~#{issue.id}") + end s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : "" s += " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})" s.html_safe diff --git a/test/helpers/issues_helper_test.rb b/test/helpers/issues_helper_test.rb index a46b44b5b..28a520b3e 100644 --- a/test/helpers/issues_helper_test.rb +++ b/test/helpers/issues_helper_test.rb @@ -375,4 +375,26 @@ class IssuesHelperTest < Redmine::HelperTest assert_equal new_project_issue_path(issue.project, params), url_for_new_subtask(issue) end + + def test_issue_spent_hours_details_should_link_to_project_time_entries_depending_on_cross_project_setting + %w(descendants).each do |setting| + with_settings :cross_project_subtasks => setting do + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 3) + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 4) + + assert_match "href=\"/projects/ecookbook/time_entries?issue_id=~1\"", issue_spent_hours_details(Issue.find(1)) + end + end + end + + def test_issue_spent_hours_details_should_link_to_global_time_entries_depending_on_cross_project_setting + %w(system tree hierarchy).each do |setting| + with_settings :cross_project_subtasks => setting do + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 3) + TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 4) + + assert_match "href=\"/time_entries?issue_id=~1\"", issue_spent_hours_details(Issue.find(1)) + end + end + end end -- 2.22.0