show_due_in_x_days.patch

Go MAEDA, 2019-06-03 02:19

Download (2.22 KB)

View differences:

app/helpers/issues_helper.rb
176 176
    end
177 177
  end
178 178

  
179
  def issue_due_date_details(issue)
180
    return if issue&.due_date.nil?
181
    s = format_date(issue.due_date)
182
    s += " (#{due_date_distance_in_words(issue.due_date)})" unless issue.closed?
183
    s
184
  end
185

  
179 186
  # Returns a link for adding a new subtask to the given issue
180 187
  def link_to_new_subtask(issue)
181 188
    attrs = {
app/views/issues/show.html.erb
59 59
    rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
60 60
  end
61 61
  unless @issue.disabled_core_fields.include?('due_date')
62
    rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
62
    rows.right l(:field_due_date), issue_due_date_details(@issue), :class => 'due-date'
63 63
  end
64 64
  unless @issue.disabled_core_fields.include?('done_ratio')
65 65
    rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :legend => "#{@issue.done_ratio}%"), :class => 'progress'
test/helpers/issues_helper_test.rb
331 331
  def test_find_name_by_reflection_should_return_nil_for_missing_record
332 332
    assert_nil find_name_by_reflection('status', 99)
333 333
  end
334

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

  
339
      # due date is not set
340
      assert_nil issue_due_date_details(issue)
341

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

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