Project

General

Profile

Patch #34654 ยป fix_overdue.patch

Stan Efremov, 2021-01-29 09:13

View differences:

app/models/issue.rb (date 1611739322377)
914 914

  
915 915
  # Returns true if the issue is overdue
916 916
  def overdue?
917
    due_date.present? && (due_date < User.current.today) && !closed?
917
    due_date && (due_date < (closed_on ? closed_on : Date.current))
918 918
  end
919 919

  
920 920
  # Is the amount of work done less than it should for the due date
test/unit/issue_test.rb (date 1611905435592)
2397 2397
  def test_overdue
2398 2398
    User.current = nil
2399 2399
    today = User.current.today
2400
    assert  Issue.new(:due_date => (today - 1.day).to_date).overdue?
2400
    closed_status = IssueStatus.where(:is_closed => true).first
2401

  
2402
    assert  Issue.new(:due_date => (today - 1.day)).overdue?
2401 2403
    assert !Issue.new(:due_date => today).overdue?
2402
    assert !Issue.new(:due_date => (today + 1.day).to_date).overdue?
2404
    assert !Issue.new(:due_date => (today + 1.day)).overdue?
2403 2405
    assert !Issue.new(:due_date => nil).overdue?
2404
    assert !Issue.new(:due_date => (today - 1.day).to_date,
2405
                      :status => IssueStatus.where(:is_closed => true).first
2406
                      ).overdue?
2406

  
2407
    assert  Issue.new(:due_date => (today - 1.day), :closed_on => today, :status => closed_status).overdue?
2408
    assert !Issue.new(:due_date => today, :closed_on => today, :status => closed_status).overdue?
2409
    assert !Issue.new(:due_date => (today + 1.day), :closed_on => today, :status => closed_status).overdue?
2410
    assert !Issue.new(:due_date => nil, :closed_on => today, :status => closed_status).overdue?
2407 2411
  end
2408 2412

  
2409 2413
  test "#behind_schedule? should be false if the issue has no start_date" do
......
3184 3188
    user_in_asia = users(:users_002)
3185 3189
    user_in_asia.pref.update! :time_zone => 'Hongkong'
3186 3190

  
3187
    issue = Issue.generate! :due_date => Date.parse('2016-03-20')
3191
    issue = Issue.generate! :due_date => Date.parse('2016-03-21')
3188 3192

  
3189 3193
    # server time is UTC
3190 3194
    time = Time.parse '2016-03-20 20:00 UTC'
    (1-1/1)