mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 12:17:30 +02:00
Implement FD notes updating
This commit is contained in:
parent
f461388783
commit
c47b093a45
6 changed files with 83 additions and 2 deletions
|
@ -84,6 +84,7 @@ module Actions
|
|||
return false if @error
|
||||
|
||||
contact.generate_code
|
||||
contact.email_history = contact.email
|
||||
contact.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,6 +112,7 @@ module Actions
|
|||
|
||||
email_changed = contact.will_save_change_to_email?
|
||||
old_email = contact.email_was
|
||||
contact.email_history = old_email
|
||||
updated = contact.save
|
||||
|
||||
if updated && email_changed && contact.registrant?
|
||||
|
|
|
@ -5,7 +5,8 @@ module Depp
|
|||
attr_accessor :id, :name, :email, :phone, :org_name,
|
||||
:ident, :ident_type, :ident_country_code,
|
||||
:street, :city, :zip, :state, :country_code,
|
||||
:password, :legal_document, :statuses, :code
|
||||
:password, :legal_document, :statuses, :code,
|
||||
:email_history
|
||||
|
||||
DISABLED = 'Disabled'
|
||||
DISCLOSURE_TYPES = [DISABLED, '1', '0']
|
||||
|
|
|
@ -62,6 +62,7 @@ class ValidationEvent < ApplicationRecord
|
|||
if object.need_to_start_force_delete?
|
||||
start_force_delete
|
||||
elsif object.need_to_lift_force_delete?
|
||||
refresh_status_notes
|
||||
lift_force_delete
|
||||
end
|
||||
end
|
||||
|
@ -70,6 +71,23 @@ class ValidationEvent < ApplicationRecord
|
|||
Domains::ForceDeleteEmail::Base.run(email: email)
|
||||
end
|
||||
|
||||
def refresh_status_notes
|
||||
old_email = object.email_history
|
||||
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
||||
registrant_ids = Registrant.where(email: email).pluck(:id)
|
||||
|
||||
domains = domain_contacts.map(&:domain).flatten +
|
||||
Domain.where(registrant_id: registrant_ids)
|
||||
|
||||
domains.uniq.each do |domain|
|
||||
next unless domain.status_notes[DomainStatus::FORCE_DELETE]
|
||||
|
||||
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(old_email)
|
||||
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
|
||||
domain.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
def lift_force_delete
|
||||
# domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
|
||||
# registrant_ids = Registrant.where(email: email).pluck(:id)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class AddEmailHistoryToContacts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :contacts, :email_history, :string
|
||||
|
||||
reversible do |dir|
|
||||
dir.up { Contact.update_all('email_history = email') }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -411,6 +411,57 @@ class ForceDeleteTest < ActionMailer::TestCase
|
|||
assert notification.text.include? asserted_text
|
||||
end
|
||||
|
||||
def test_force_delete_notes
|
||||
domain = domains(:airport)
|
||||
domain.update(valid_to: Time.zone.parse('2012-08-05'))
|
||||
assert_not domain.force_delete_scheduled?
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
email_1 = '`@internet.ee'
|
||||
asserted_text = "Invalid email: #{email_1}"
|
||||
|
||||
Truemail.configure.default_validation_type = :regex
|
||||
|
||||
contact_first = domain.admin_contacts.first
|
||||
contact_first.update_attribute(:email, email_1)
|
||||
|
||||
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
|
||||
contact_first.verify_email
|
||||
end
|
||||
|
||||
assert contact_first.email_verification_failed?
|
||||
|
||||
domain.reload
|
||||
email_2 = '`@internet2.ee'
|
||||
contact_second = domain.admin_contacts.last
|
||||
contact_second.update_attribute(:email, email_2)
|
||||
|
||||
ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD.times do
|
||||
contact_second.verify_email
|
||||
end
|
||||
|
||||
assert contact_second.email_verification_failed?
|
||||
|
||||
domain.reload
|
||||
contact_first.update(
|
||||
email: 'correct_email@internet2.ee',
|
||||
email_history: email_1
|
||||
)
|
||||
|
||||
|
||||
contact_first.verify_email
|
||||
|
||||
|
||||
domain.reload
|
||||
assert domain.force_delete_scheduled?
|
||||
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-08-05'), domain.force_delete_start.to_date
|
||||
|
||||
assert_equal domain.status_notes[DomainStatus::FORCE_DELETE], email_2
|
||||
notification = domain.registrar.notifications.last
|
||||
assert notification.text.include? asserted_text
|
||||
end
|
||||
|
||||
def test_domain_should_have_several_bounced_emails
|
||||
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
|
@ -458,7 +509,7 @@ class ForceDeleteTest < ActionMailer::TestCase
|
|||
notification = @domain.registrar.notifications.last
|
||||
assert notification.text.include? asserted_text
|
||||
|
||||
@domain.registrant.update(email: 'aaa@bbb.com')
|
||||
@domain.registrant.update(email: 'aaa@bbb.com', email_history: email)
|
||||
@domain.registrant.verify_email
|
||||
assert @domain.registrant.need_to_lift_force_delete?
|
||||
CheckForceDeleteLift.perform_now
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue