Browse Source

Show "Due in X days" in issue details page (#31499).

Patch by Go MAEDA.


git-svn-id: http://svn.redmine.org/redmine/trunk@18236 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.1.0
Go MAEDA 5 years ago
parent
commit
a12a6f6c3e
3 changed files with 27 additions and 1 deletions
  1. 7
    0
      app/helpers/issues_helper.rb
  2. 1
    1
      app/views/issues/show.html.erb
  3. 19
    0
      test/helpers/issues_helper_test.rb

+ 7
- 0
app/helpers/issues_helper.rb View File

@@ -176,6 +176,13 @@ module IssuesHelper
end
end

def issue_due_date_details(issue)
return if issue&.due_date.nil?
s = format_date(issue.due_date)
s += " (#{due_date_distance_in_words(issue.due_date)})" unless issue.closed?
s
end

# Returns a link for adding a new subtask to the given issue
def link_to_new_subtask(issue)
attrs = {

+ 1
- 1
app/views/issues/show.html.erb View File

@@ -59,7 +59,7 @@
rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
end
unless @issue.disabled_core_fields.include?('due_date')
rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
rows.right l(:field_due_date), issue_due_date_details(@issue), :class => 'due-date'
end
unless @issue.disabled_core_fields.include?('done_ratio')
rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :legend => "#{@issue.done_ratio}%"), :class => 'progress'

+ 19
- 0
test/helpers/issues_helper_test.rb View File

@@ -331,4 +331,23 @@ class IssuesHelperTest < Redmine::HelperTest
def test_find_name_by_reflection_should_return_nil_for_missing_record
assert_nil find_name_by_reflection('status', 99)
end

def test_issue_due_date_details
travel_to DateTime.parse('2019-06-01') do
issue = Issue.generate!

# due date is not set
assert_nil issue_due_date_details(issue)

# due date is set
issue.due_date = 5.days.from_now
issue.save!
assert_equal '06/06/2019 (Due in 5 days)', issue_due_date_details(issue)

# Don't show "Due in X days" if the issue is closed
issue.status = IssueStatus.find_by_is_closed(true)
issue.save!
assert_equal '06/06/2019', issue_due_date_details(issue)
end
end
end

Loading…
Cancel
Save