Feature #31499 » show_due_in_x_days-v2.patch
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 |
if !issue.closed? && (issue.start_date.nil? || issue.start_date <= User.current.today) |
|
183 |
s += " (#{due_date_distance_in_words(issue.due_date)})" |
|
184 |
end |
|
185 |
s |
|
186 |
end |
|
187 | ||
179 | 188 |
# Returns a link for adding a new subtask to the given issue |
180 | 189 |
def link_to_new_subtask(issue) |
181 | 190 |
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 |
# start date is nil and due date is set |
|
343 |
issue.start_date = nil |
|
344 |
issue.due_date = 5.days.from_now |
|
345 |
issue.save! |
|
346 |
assert_equal '06/06/2019 (Due in 5 days)', issue_due_date_details(issue) |
|
347 | ||
348 |
# start date is today or a past date, and due date is set |
|
349 |
issue.start_date = User.current.today |
|
350 |
issue.due_date = 5.days.from_now |
|
351 |
issue.save! |
|
352 |
assert_equal '06/06/2019 (Due in 5 days)', issue_due_date_details(issue) |
|
353 | ||
354 |
# Dont show "Due in X days" if the start date is a future date |
|
355 |
issue.start_date = 1.days.from_now |
|
356 |
issue.due_date = 5.days.from_now |
|
357 |
issue.save! |
|
358 |
assert_equal '06/06/2019', issue_due_date_details(issue) |
|
359 | ||
360 |
# Don't show "Due in X days" if the issue is closed |
|
361 |
issue.status = IssueStatus.find_by_is_closed(true) |
|
362 |
issue.save! |
|
363 |
assert_equal '06/06/2019', issue_due_date_details(issue) |
|
364 |
end |
|
365 |
end |
|
334 | 366 |
end |
- « Previous
- 1
- 2
- 3
- Next »