added test

This commit is contained in:
Oleg Hasjanov 2024-01-11 14:24:27 +02:00
parent 1b8640966c
commit 736d935e3e
5 changed files with 27 additions and 8 deletions

View file

@ -3,13 +3,20 @@ module EmailVerifable
included do
scope :recently_not_validated, -> { where.not(id: ValidationEvent.validated_ids_by(name)) }
end
after_save :verify_email, if: :email_changed?
def validate_email_by_regex_and_mx
return if Rails.env.test?
verify_email(check_level: 'regex')
verify_email(check_level: 'mx')
end
def remove_force_delete
return if Rails.env.test?
domains.each do |domain|
contact_emails_valid?(domain) ? domain.cancel_force_delete : domain.schedule_force_delete
contact_emails_valid?(domain) ? domain.cancel_force_delete : nil
end
end

View file

@ -85,6 +85,9 @@ class Contact < ApplicationRecord
after_save :update_related_whois_records
before_validation :clear_address_modifications, if: -> { !self.class.address_processing? }
after_save :validate_email_by_regex_and_mx, if: :email_previously_changed?
after_save :remove_force_delete, if: :email_previously_changed?
self.ignored_columns = %w[legacy_id legacy_history_id]
ORG = 'org'.freeze