Defect #35134

Change total spent time link to global time entries when issue has subtasks that can be on non descendent projects

Added by Dmitry Makurin 6 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Issues
Target version:4.1.4
Resolution:Fixed Affected version:4.2.0

Description

Parent issue displays total spent hours. It includes self time entries and all of subtasks and also gives user a link to time_entries controller. Link leads to time_entries inside a parent issue project so if any of subtask will be in different project than parent you won't see it.

Issue.total_spent_hours does not filter time entries by a project.

I guess it's more natural to give link to time_entries instead projects/:id/time_entries.

Index: app/helpers/issues_helper.rb
<+>UTF-8
===================================================================
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
--- a/app/helpers/issues_helper.rb    (revision ad087516f4f11bb530ea96777e3edc32940e323b)
+++ b/app/helpers/issues_helper.rb    (revision 3c8f6a9152e28c5057710f68b13559db56990dbf)
@@ -259,7 +259,7 @@

   def issue_spent_hours_details(issue)
     if issue.total_spent_hours > 0
-      path = project_time_entries_path(issue.project, :issue_id => "~#{issue.id}")
+      path = time_entries_path(:issue_id => "~#{issue.id}")

       if issue.total_spent_hours == issue.spent_hours
         link_to(l_hours_short(issue.spent_hours), path)

0001-Link-to-global-time-entries-if-issue-has-subtasks-an.patch Magnifier (2.71 KB) Marius BALTEANU, 2021-07-03 15:57

Associated revisions

Revision 21082
Added by Marius BALTEANU 3 months ago

Link total spent time to global time entries page when cross_project_issue_relations are allowed in order to include time entries from other projects (#35134).

Revision 21085
Added by Marius BALTEANU 3 months ago

Total spent time from issue page should link to global time entries if the issue has subtasks and the subtasks can be on projects that are not descendants of the current project (#35134).

Revision 21092
Added by Marius BALTEANU 3 months ago

Merged r21085 to 4.2-stable (#35134).

Revision 21095
Added by Marius BALTEANU 3 months ago

Merged r21085 to 4.1-stable (#35134).

Revision 21102
Added by Marius BALTEANU 3 months ago

Fixes failing tests on Ruby 2.4 (#35134).

Revision 21103
Added by Marius BALTEANU 3 months ago

Merged r21102 to 4.1-stable (#35134).

History

#1 Updated by Marius BALTEANU 6 months ago

  • Assignee set to Marius BALTEANU
  • Target version set to 4.1.4

#2 Updated by Marius BALTEANU 5 months ago

  • Status changed from New to Needs feedback
  • Assignee deleted (Marius BALTEANU)

Indeed, giving link to time_entries instead projects/:id/time_entries fixes this, but with a downside, the user context is changed from project level to global level.

What about setting the link to time_entries only when the "Allow cross-projects subtasks" is set to "With all projects"? If I'm not wrong, this is the only case when this issue reproduces.

#3 Updated by Marius BALTEANU 5 months ago

  • Assignee set to Marius BALTEANU

#4 Updated by Dmitry Makurin 5 months ago

Marius BALTEANU wrote:

What about setting the link to time_entries only when the "Allow cross-projects subtasks" is set to "With all projects"? If I'm not wrong, this is the only case when this issue reproduces.

Yes, it is. Agreed that is a better approach, I'll try to redo the patch.

#6 Updated by Marius BALTEANU 4 months ago

The implementation links to global path instead of project path only when:
  • the total spent time is greater than spent time (means that the issue has subtasks with time entries logged) and
  • setting "Allow cross-project subtasks" is "With all projects", "With project tree" or "With project hierarchy".

#7 Updated by Marius BALTEANU 3 months ago

  • Status changed from Needs feedback to Resolved

Patch committed.

#8 Updated by Marius BALTEANU 3 months ago

  • Resolution set to Fixed

#9 Updated by Marius BALTEANU 3 months ago

  • Status changed from Resolved to Closed

#10 Updated by Go MAEDA 3 months ago

  • Status changed from Closed to Reopened

IssuesHelperTest in 4.2-stable and 4.1-stable branches fails with Ruby 2.4.

laphroaig:4.2-stable maeda$ ruby test/helpers/issues_helper_test.rb
Run options: --seed 4533

# Running:

....F

Failure:
IssuesHelperTest#test_issue_spent_hours_details_should_link_to_project_time_entries_depending_on_cross_project_setting [test/helpers/issues_helper_test.rb:385]:
Expected /href="\/projects\/ecookbook\/time_entries\?issue_id=~1"/ to match "154.25 h (Total: <a href=\"/projects/ecookbook/time_entries?issue_id=%7E1\">161.25 h</a>)".

bin/rails test test/helpers/issues_helper_test.rb:379

...........................F

Failure:
IssuesHelperTest#test_issue_spent_hours_details_should_link_to_global_time_entries_depending_on_cross_project_setting [test/helpers/issues_helper_test.rb:396]:
Expected /href="\/time_entries\?issue_id=~1"/ to match "154.25 h (Total: <a href=\"/time_entries?issue_id=%7E1\">161.25 h</a>)".

bin/rails test test/helpers/issues_helper_test.rb:390

#11 Updated by Marius BALTEANU 3 months ago

Thanks for reporting the failures, I've committed the fixes.

Considering that the issue reproduces only on Ruby 2.4 which is no longer supported on trunk, is it ok to fix the tests only on 4.2-stable and 4.1-stable branches?

#12 Updated by Marius BALTEANU 3 months ago

  • Status changed from Reopened to Closed

#13 Updated by Marius BALTEANU 3 months ago

  • Subject changed from Change total spent time link to global time entries to Change total spent time link to global time entries when issue has subtasks that can be on non descendent projects

#14 Updated by Marius BALTEANU 3 months ago

  • Category set to Issues

Also available in: Atom PDF