Project

General

Profile

Defect #35134 » 0001-Link-to-global-time-entries-if-issue-has-subtasks-an.patch

Marius BĂLTEANU, 2021-07-03 15:57

View differences:

app/helpers/issues_helper.rb
264 264
      if issue.total_spent_hours == issue.spent_hours
265 265
        link_to(l_hours_short(issue.spent_hours), path)
266 266
      else
267
        # link to global time entries if cross-project subtasks are allowed
268
        # in order to show time entries from not descendents projects
269
        if %w(system tree hierarchy).include?(Setting.cross_project_subtasks)
270
          path = time_entries_path(:issue_id => "~#{issue.id}")
271
        end
267 272
        s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : ""
268 273
        s += " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})"
269 274
        s.html_safe
test/helpers/issues_helper_test.rb
375 375
    assert_equal new_project_issue_path(issue.project, params),
376 376
                 url_for_new_subtask(issue)
377 377
  end
378

  
379
  def test_issue_spent_hours_details_should_link_to_project_time_entries_depending_on_cross_project_setting
380
    %w(descendants).each do |setting|
381
      with_settings :cross_project_subtasks => setting do
382
        TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 3)
383
        TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 4)
384

  
385
        assert_match "href=\"/projects/ecookbook/time_entries?issue_id=~1\"", issue_spent_hours_details(Issue.find(1))
386
      end
387
    end
388
  end
389

  
390
  def test_issue_spent_hours_details_should_link_to_global_time_entries_depending_on_cross_project_setting
391
    %w(system tree hierarchy).each do |setting|
392
      with_settings :cross_project_subtasks => setting do
393
        TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 3)
394
        TimeEntry.generate!(:issue => Issue.generate!(:parent_issue_id => 1), :hours => 4)
395

  
396
        assert_match "href=\"/time_entries?issue_id=~1\"", issue_spent_hours_details(Issue.find(1))
397
      end
398
    end
399
  end
378 400
end
    (1-1/1)