Project

General

Profile

Patch #35919 » illumination_of_overdue_closed_issues.patch

Gry Adams, 2021-09-24 19:03

View differences:

app/models/issue.rb (revision e4b47acbc7e7dba269965d62a75683e46f30307e) → app/models/issue.rb (revision 190a8835f1946a51b99eee8362996d16b52b9dec)
949 949

  
950 950
  # Returns true if the issue is overdue
951 951
  def overdue?
952
    due_date.present? && (due_date < User.current.today) && !closed?
952
    due_date && (due_date < (status.is_closed ? closed_on.to_date : Date.current))
953 953
  end
954 954

  
955 955
  # Is the amount of work done less than it should for the due date
test/unit/issue_test.rb (revision e4b47acbc7e7dba269965d62a75683e46f30307e) → test/unit/issue_test.rb (revision 190a8835f1946a51b99eee8362996d16b52b9dec)
2494 2494
  def test_overdue
2495 2495
    User.current = nil
2496 2496
    today = User.current.today
2497
    assert  Issue.new(:due_date => (today - 1.day).to_date).overdue?
2498
    assert !Issue.new(:due_date => today).overdue?
2499
    assert !Issue.new(:due_date => (today + 1.day).to_date).overdue?
2500
    assert !Issue.new(:due_date => nil).overdue?
2501
    assert !Issue.
2502
              new(
2503
                :due_date => (today - 1.day).to_date,
2504
                :status => IssueStatus.where(:is_closed => true).first
2505
              ).overdue?
2497
    opened_status = IssueStatus.where(:is_closed => false).first
2498
    closed_status = IssueStatus.where(:is_closed => true).first
2499
    assert  Issue.new(:due_date => (today - 1.day), :status => opened_status).overdue?
2500
    assert !Issue.new(:due_date => today, :status => opened_status).overdue?
2501
    assert !Issue.new(:due_date => (today + 1.day), :status => opened_status).overdue?
2502
    assert !Issue.new(:due_date => nil, :status => opened_status).overdue?
2503

  
2504
    assert  Issue.new(:due_date => (today - 1.day), :closed_on => today, :status => closed_status).overdue?
2505
    assert !Issue.new(:due_date => today, :closed_on => today, :status => closed_status).overdue?
2506
    assert !Issue.new(:due_date => (today + 1.day), :closed_on => today, :status => closed_status).overdue?
2507
    assert !Issue.new(:due_date => nil, :closed_on => today, :status => closed_status).overdue?
2506 2508
  end
2507 2509

  
2508 2510
  test "#behind_schedule? should be false if the issue has no start_date" do
(1-1/2)