mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
Fix tests and errors
This commit is contained in:
parent
d5e6ba1e69
commit
8cab4f6df4
3 changed files with 28 additions and 9 deletions
|
@ -23,11 +23,20 @@ module Domains
|
||||||
def before_execute_force_delete(domain)
|
def before_execute_force_delete(domain)
|
||||||
if domain.force_delete_scheduled? && !domain.status_notes[DomainStatus::FORCE_DELETE].nil?
|
if domain.force_delete_scheduled? && !domain.status_notes[DomainStatus::FORCE_DELETE].nil?
|
||||||
added_additional_email_into_notes(domain)
|
added_additional_email_into_notes(domain)
|
||||||
|
notify_registrar(domain)
|
||||||
else
|
else
|
||||||
process_force_delete(domain)
|
process_force_delete(domain)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_registrar(domain)
|
||||||
|
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
|
||||||
|
domain_name: domain.name,
|
||||||
|
outzone_date: domain.outzone_date,
|
||||||
|
purge_date: domain.purge_date,
|
||||||
|
email: domain.status_notes[DomainStatus::FORCE_DELETE]))
|
||||||
|
end
|
||||||
|
|
||||||
def process_force_delete(domain)
|
def process_force_delete(domain)
|
||||||
domain.schedule_force_delete(type: :soft,
|
domain.schedule_force_delete(type: :soft,
|
||||||
notify_by_email: true,
|
notify_by_email: true,
|
||||||
|
|
|
@ -85,9 +85,19 @@ class ValidationEvent < ApplicationRecord
|
||||||
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(old_email)
|
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(old_email)
|
||||||
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
|
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
|
||||||
domain.save(validate: false)
|
domain.save(validate: false)
|
||||||
|
|
||||||
|
notify_registrar(domain) unless domain.status_notes[DomainStatus::FORCE_DELETE].empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_registrar(domain)
|
||||||
|
domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
|
||||||
|
domain_name: domain.name,
|
||||||
|
outzone_date: domain.outzone_date,
|
||||||
|
purge_date: domain.purge_date,
|
||||||
|
email: domain.status_notes[DomainStatus::FORCE_DELETE]))
|
||||||
|
end
|
||||||
|
|
||||||
def lift_force_delete
|
def lift_force_delete
|
||||||
# domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
# domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
||||||
# registrant_ids = Registrant.where(email: email).pluck(:id)
|
# registrant_ids = Registrant.where(email: email).pluck(:id)
|
||||||
|
|
|
@ -424,10 +424,8 @@ class ForceDeleteTest < ActionMailer::TestCase
|
||||||
|
|
||||||
contact_first = domain.admin_contacts.first
|
contact_first = domain.admin_contacts.first
|
||||||
old_email = contact_first.email
|
old_email = contact_first.email
|
||||||
contact_first.update(
|
contact_first.update_attribute(:email_history, old_email)
|
||||||
email: email_1,
|
contact_first.update_attribute(:email, email_1)
|
||||||
email_history: old_email
|
|
||||||
)
|
|
||||||
|
|
||||||
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
|
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
|
||||||
contact_first.verify_email
|
contact_first.verify_email
|
||||||
|
@ -439,6 +437,7 @@ class ForceDeleteTest < ActionMailer::TestCase
|
||||||
contact_second = domain.admin_contacts.last
|
contact_second = domain.admin_contacts.last
|
||||||
contact_second.update_attribute(:email, email_2)
|
contact_second.update_attribute(:email, email_2)
|
||||||
|
|
||||||
|
travel_to Time.zone.parse('2010-07-05 0:00:03')
|
||||||
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
|
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
|
||||||
contact_second.verify_email
|
contact_second.verify_email
|
||||||
end
|
end
|
||||||
|
@ -446,14 +445,15 @@ class ForceDeleteTest < ActionMailer::TestCase
|
||||||
assert contact_second.email_verification_failed?
|
assert contact_second.email_verification_failed?
|
||||||
|
|
||||||
domain.reload
|
domain.reload
|
||||||
contact_first.update(
|
contact_first.update_attribute(:email_history, email_1)
|
||||||
email: old_email,
|
contact_first.update_attribute(:email, 'correct_email@internet.ee')
|
||||||
email_history: email_1
|
|
||||||
)
|
|
||||||
|
|
||||||
|
travel_to Time.zone.parse('2010-07-05 0:00:06')
|
||||||
contact_first.verify_email
|
contact_first.verify_email
|
||||||
|
|
||||||
domain.reload
|
domain.reload
|
||||||
|
|
||||||
|
assert contact_first.need_to_lift_force_delete?
|
||||||
|
|
||||||
assert domain.force_delete_scheduled?
|
assert domain.force_delete_scheduled?
|
||||||
assert_equal 'invalid_email', domain.template_name
|
assert_equal 'invalid_email', domain.template_name
|
||||||
assert_equal Date.parse('2010-09-19'), domain.force_delete_date.to_date
|
assert_equal Date.parse('2010-09-19'), domain.force_delete_date.to_date
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue