Add FD if email belongs to registant

This commit is contained in:
Alex Sherman 2021-03-19 18:19:28 +05:00
parent a3260bb5bf
commit 81c21db392
2 changed files with 20 additions and 1 deletions

View file

@ -6,7 +6,11 @@ module Domains
def execute
domain_contacts = Contact.where(email: email).map(&:domain_contacts).flatten
domains = domain_contacts.map(&:domain).flatten
registrant_ids = Registrant.where(email: email).pluck(:id)
domains = domain_contacts.map(&:domain).flatten +
Domain.where(registrant_id: registrant_ids)
domains.each do |domain|
next if domain.force_delete_scheduled?

View file

@ -336,6 +336,21 @@ class ForceDeleteTest < ActionMailer::TestCase
assert_equal Date.parse('2010-08-05'), @domain.force_delete_start.to_date
end
def test_schedules_force_delete_after_registrant_bounce
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
assert_not @domain.force_delete_scheduled?
travel_to Time.zone.parse('2010-07-05')
prepare_bounced_email_address(@domain.registrant.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
end
def test_schedules_force_delete_invalid_contact
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
assert_not @domain.force_delete_scheduled?