21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-04-26 05:50:50 +02:00

Do not mark a check in error when last run occured a few days ago (when run was successful)

This commit is contained in:
Colin Darie 2018-07-24 14:06:34 +02:00
parent aa97430e13
commit 9e8231d52c
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 7 additions and 0 deletions

View file

@ -76,6 +76,7 @@ class Check < ApplicationRecord
return false if created_at > ERROR_DELAY_DAYS.days.ago
return false if last_run_at.nil?
return true if last_success_at.nil?
return false if last_run_at == last_success_at
last_success_at < ERROR_DELAY_DAYS.days.ago
end

View file

@ -84,6 +84,12 @@ class CheckTest < ActiveSupport::TestCase
refute check.in_error?
end
test "in_error? when last check occured a few days ago without error" do
check = build(:check, created_at: 3.weeks.ago,
last_success_at: 10.days.ago, last_run_at: 10.days.ago)
refute check.in_error?
end
test "days_from_last_success without any success" do
check = build(:check)
assert_nil check.days_from_last_success