Project

General

Profile

Patch #35919 » illumination_of_overdue_closed_issues_with_user_current_today.patch

Gry Adams, 2021-09-24 21:25

View differences:

app/models/issue.rb
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 : User.current.today))
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
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
    assert  Issue.new(:due_date => (today - 1.day), :closed_on => today, :status => closed_status).overdue?
2504
    assert !Issue.new(:due_date => today, :closed_on => today, :status => closed_status).overdue?
2505
    assert !Issue.new(:due_date => (today + 1.day), :closed_on => today, :status => closed_status).overdue?
2506
    assert !Issue.new(:due_date => nil, :closed_on => today, :status => closed_status).overdue?
2506 2507
  end
2507 2508

  
2508 2509
  test "#behind_schedule? should be false if the issue has no start_date" do
2509 2510

  
(2-2/2)