mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
added tests
This commit is contained in:
parent
e74cf2bc7f
commit
d6824bf46c
5 changed files with 94 additions and 5 deletions
|
@ -45,7 +45,8 @@ module Repp
|
|||
end
|
||||
|
||||
def notify_admins
|
||||
admin_users_emails = User.all.reject { |u| u.roles.nil? }.select { |u| u.roles.include? "admin" }.pluck(:email)
|
||||
admin_users_emails = User.all.reject { |u| u.roles.nil? }.
|
||||
select { |u| u.roles.include? 'admin' }.pluck(:email)
|
||||
|
||||
return if admin_users_emails.empty?
|
||||
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
class NotifyAccreditationAdminsAndRegistrarsJob < ApplicationJob
|
||||
MONTH_BEFORE = 5.minute.freeze
|
||||
MONTH_BEFORE = 5.minutes.freeze
|
||||
|
||||
def perform
|
||||
notify_month_before
|
||||
notify_date_is_expired
|
||||
end
|
||||
|
||||
def notify_month_before
|
||||
prepare_data_month_before.each do |user|
|
||||
next if user.registrar.email.nil?
|
||||
|
||||
AccreditationCenterMailer.test_results_will_expired_in_one_month(user.registrar.email).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
def notify_date_is_expired
|
||||
prepare_data_expired_data.each do |user|
|
||||
next if user.registrar.email.nil?
|
||||
|
||||
|
@ -19,11 +26,11 @@ class NotifyAccreditationAdminsAndRegistrarsJob < ApplicationJob
|
|||
|
||||
def prepare_data_month_before
|
||||
ApiUser.where("accreditation_expire_date > ? AND accreditation_expire_date < ?",
|
||||
Time.now.beginning_of_day + MONTH_BEFORE,
|
||||
Time.now.end_of_day + MONTH_BEFORE).includes(:registrar)
|
||||
Time.zone.now.beginning_of_day + MONTH_BEFORE,
|
||||
Time.zone.now.end_of_day + MONTH_BEFORE).includes(:registrar)
|
||||
end
|
||||
|
||||
def prepare_data_expired_data
|
||||
ApiUser.where("accreditation_expire_date < ?", Time.now.beginning_of_day).includes(:registrar)
|
||||
ApiUser.where("accreditation_expire_date < ?", Time.zone.now.beginning_of_day).includes(:registrar)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue