mirror of
https://github.com/Evolix/chexpire.git
synced 2024-04-28 23:10:49 +02:00
Reset consecutive failures after changing domain or mode
This commit is contained in:
parent
95b437bf3d
commit
ccde868457
|
@ -128,7 +128,7 @@ class Check < ApplicationRecord
|
|||
end
|
||||
|
||||
def reset_consecutive_failures
|
||||
return unless last_success_at_changed?
|
||||
return unless last_success_at_changed? || mode_changed? || domain_changed?
|
||||
return if consecutive_failures_changed?
|
||||
|
||||
self.consecutive_failures = 0
|
||||
|
|
|
@ -55,6 +55,27 @@ class CheckTest < ActiveSupport::TestCase
|
|||
assert_nil check_notification.sent_at
|
||||
end
|
||||
|
||||
test "consecutive failures are resetted when domain changed" do
|
||||
check = create(:check, consecutive_failures: 1)
|
||||
|
||||
check.domain = "mynewdomain.fr"
|
||||
check.save!
|
||||
|
||||
assert_equal 0, check.consecutive_failures
|
||||
end
|
||||
|
||||
test "consecutive failures are resetted when mode changed" do
|
||||
check = create(:check, consecutive_failures: 1, mode: :auto)
|
||||
check.manual!
|
||||
|
||||
assert_equal 0, check.consecutive_failures
|
||||
|
||||
check = create(:check, domain: "x.wxyz", consecutive_failures: 1, mode: :manual)
|
||||
check.auto!
|
||||
|
||||
assert_equal 0, check.consecutive_failures
|
||||
end
|
||||
|
||||
test "days_from_last_success without any success" do
|
||||
check = build(:check)
|
||||
assert_nil check.days_from_last_success
|
||||
|
|
Loading…
Reference in a new issue