-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oleg Hasjanov
authored and
Oleg Hasjanov
committed
Jan 11, 2024
1 parent
ee8ab80
commit a621b0d
Showing
5 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,6 +321,61 @@ def test_remove_email_whitespaces | |
assert_equal contact.email, '[email protected]' | ||
end | ||
|
||
def test_verify_email_if_it_changed | ||
Contact.set_callback(:save, :after, :validate_email_by_regex_and_mx) | ||
|
||
# check that email is invalid | ||
assert_equal @contact.validation_events.count, 0 | ||
|
||
trumail_results = OpenStruct.new(success: false, | ||
email: @contact.email, | ||
domain: 'box.tests', | ||
errors: { mx: 'target host(s) not found' }) | ||
|
||
runner = Actions::EmailCheck.new(email: @contact.email, | ||
validation_eventable: @contact, | ||
check_level: 'mx') | ||
|
||
runner.stub :call, trumail_results do | ||
3.times do | ||
perform_enqueued_jobs do | ||
VerifyEmailsJob.perform_now(email: @contact.email, check_level: 'mx') | ||
end | ||
end | ||
end | ||
|
||
assert_equal @contact.validation_events.count, 3 | ||
validation_event = @contact.validation_events.last | ||
|
||
assert_equal validation_event.check_level, 'mx' | ||
assert_equal validation_event.success, false | ||
|
||
# set force delete to releted contact domain because invlid email | ||
assert @contact.need_to_start_force_delete? | ||
|
||
@contact.domains.each do |domain| | ||
domain.schedule_force_delete(type: :soft) | ||
end | ||
|
||
# check it | ||
assert @contact.domains.first.force_delete_scheduled? | ||
|
||
# change email to valid | ||
|
||
Truemail.configure.whitelisted_domains = ['email.com'] | ||
|
||
@contact.email = '[email protected]' | ||
@contact.save && @contact.reload | ||
|
||
@contact.reload | ||
|
||
assert_equal @contact.validation_events.count, 1 | ||
|
||
# check that force delete is removed | ||
|
||
assert_not @contact.domains.first.force_delete_scheduled? | ||
end | ||
|
||
private | ||
|
||
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ class ForceDeleteTest < ActionMailer::TestCase | |
ActionMailer::Base.deliveries.clear | ||
@old_validation_type = Truemail.configure.default_validation_type | ||
ValidationEvent.destroy_all | ||
|
||
Truemail.configure.whitelisted_domains = ['email.com', 'internet2.ee'] | ||
end | ||
|
||
teardown do | ||
|
@@ -403,6 +405,8 @@ def test_schedules_force_delete_invalid_contact | |
end | ||
|
||
def test_add_invalid_email_to_domain_status_notes | ||
Contact.skip_callback(:save, :after, :remove_force_delete) | ||
|
||
domain = domains(:airport) | ||
domain.update(valid_to: Time.zone.parse('2012-08-05'), | ||
statuses: %w[serverForceDelete serverRenewProhibited serverTransferProhibited], | ||
|
@@ -417,6 +421,8 @@ def test_add_invalid_email_to_domain_status_notes | |
Truemail.configure.default_validation_type = :regex | ||
|
||
contact_first = domain.admin_contacts.first | ||
|
||
|
||
contact_first.update_attribute(:email_history, '[email protected]') | ||
contact_first.update_attribute(:email, email) | ||
|
||
|
@@ -461,6 +467,8 @@ def test_remove_invalid_email_from_domain_status_notes | |
end | ||
|
||
def test_domain_should_have_several_bounced_emails | ||
Contact.skip_callback(:save, :after, :validate_email_by_regex_and_mx) | ||
|
||
@domain.update(valid_to: Time.zone.parse('2012-08-05')) | ||
assert_not @domain.force_delete_scheduled? | ||
travel_to Time.zone.parse('2010-07-05') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ def test_fd_didnt_set_if_mx_interation_less_then_value | |
assert_not @domain.force_delete_scheduled? | ||
travel_to Time.zone.parse('2010-07-05') | ||
|
||
Contact.skip_callback(:save, :after, :validate_email_by_regex_and_mx) | ||
email = '[email protected]' | ||
contact = @domain.admin_contacts.first | ||
contact.update_attribute(:email, email) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters