mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-17 07:58:39 +02:00
Merge ce143201b5
into 7e356e369e
This commit is contained in:
commit
83c75a2713
|
@ -22,7 +22,7 @@ module Notifier
|
||||||
.deliver_now
|
.deliver_now
|
||||||
end
|
end
|
||||||
|
|
||||||
def ssl_notify_expires_soon(_notification)
|
def ssl_notify_expires_soon(check_notification)
|
||||||
NotificationsMailer.with(check_notification: check_notification)
|
NotificationsMailer.with(check_notification: check_notification)
|
||||||
.ssl_expires_soon
|
.ssl_expires_soon
|
||||||
.deliver_now
|
.deliver_now
|
||||||
|
|
|
@ -13,6 +13,7 @@ module Notifier
|
||||||
def checks_recurrent_failures(min_consecutive)
|
def checks_recurrent_failures(min_consecutive)
|
||||||
Check
|
Check
|
||||||
.active
|
.active
|
||||||
|
.auto
|
||||||
.consecutive_failures(min_consecutive)
|
.consecutive_failures(min_consecutive)
|
||||||
.includes(:user)
|
.includes(:user)
|
||||||
.where.not(user: ignore_users)
|
.where.not(user: ignore_users)
|
||||||
|
|
|
@ -84,6 +84,15 @@ FactoryBot.define do
|
||||||
active false
|
active false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :auto do
|
||||||
|
mode :auto
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :manual do
|
||||||
|
mode :manual
|
||||||
|
domain "unupported.wxyz"
|
||||||
|
end
|
||||||
|
|
||||||
trait :with_notifications do
|
trait :with_notifications do
|
||||||
after :create do |check|
|
after :create do |check|
|
||||||
create_list :check_notification, 2,
|
create_list :check_notification, 2,
|
||||||
|
|
|
@ -6,13 +6,17 @@ class NotificationsMailerPreview < ActionMailer::Preview
|
||||||
# Preview this email at http://localhost:3000/rails/mailers/notifications_mailer/domain_expires_soon
|
# Preview this email at http://localhost:3000/rails/mailers/notifications_mailer/domain_expires_soon
|
||||||
def domain_expires_soon
|
def domain_expires_soon
|
||||||
check = Check.domain.first
|
check = Check.domain.first
|
||||||
NotificationsMailer.with(notification: check.notifications.first).domain_expires_soon
|
NotificationsMailer
|
||||||
|
.with(check_notification: check.check_notifications.first)
|
||||||
|
.domain_expires_soon
|
||||||
end
|
end
|
||||||
|
|
||||||
# Preview this email at http://localhost:3000/rails/mailers/notifications_mailer/ssl_expires_soon
|
# Preview this email at http://localhost:3000/rails/mailers/notifications_mailer/ssl_expires_soon
|
||||||
def ssl_expires_soon
|
def ssl_expires_soon
|
||||||
check = Check.ssl.first
|
check = Check.ssl.first
|
||||||
NotificationsMailer.with(notification: check.notifications.first).ssl_expires_soon
|
NotificationsMailer
|
||||||
|
.with(check_notification: check.check_notifications.first)
|
||||||
|
.ssl_expires_soon
|
||||||
end
|
end
|
||||||
|
|
||||||
# Preview this email at http://localhost:3000/rails/mailers/notifications_mailer/recurrent_failures
|
# Preview this email at http://localhost:3000/rails/mailers/notifications_mailer/recurrent_failures
|
||||||
|
|
|
@ -91,6 +91,16 @@ module Notifier
|
||||||
assert_includes checks, c2
|
assert_includes checks, c2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "#checks_recurrent_failures ignores manual checks" do
|
||||||
|
c1 = create(:check, :last_runs_failed, :manual)
|
||||||
|
c2 = create(:check, :last_runs_failed, :auto)
|
||||||
|
|
||||||
|
checks = @resolver.checks_recurrent_failures(4)
|
||||||
|
|
||||||
|
assert_not_includes checks, c1
|
||||||
|
assert_includes checks, c2
|
||||||
|
end
|
||||||
|
|
||||||
test "#checks_recurrent_failures ignores user having notification disabled" do
|
test "#checks_recurrent_failures ignores user having notification disabled" do
|
||||||
c1 = create(:check, :last_runs_failed)
|
c1 = create(:check, :last_runs_failed)
|
||||||
c1.user.update_attribute(:notifications_enabled, false)
|
c1.user.update_attribute(:notifications_enabled, false)
|
||||||
|
|
Loading…
Reference in a new issue