mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Add tests
This commit is contained in:
parent
0116531786
commit
6a4bb6079d
4 changed files with 22 additions and 12 deletions
|
@ -22,7 +22,7 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
|||
def notification_template
|
||||
if contact_emails_verification_failed.present?
|
||||
'invalid_email'
|
||||
elsif registrant.org?
|
||||
elsif registrant.org?
|
||||
'legal_person'
|
||||
else
|
||||
'private_person'
|
||||
|
|
|
@ -16,7 +16,7 @@ module Concerns
|
|||
end
|
||||
|
||||
def email_verification_failed?
|
||||
email_verification.failed?
|
||||
email_verification&.failed?
|
||||
end
|
||||
|
||||
class_methods do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class DomainDeleteMailerPreview < ActionMailer::Preview
|
||||
def self.define_forced_templates
|
||||
DomainDeleteMailer.force_delete_templates.each do |template_name|
|
||||
%w[private_person legal_person invalid_email].each do |template_name|
|
||||
define_method "forced_#{template_name}".to_sym do
|
||||
DomainDeleteMailer.forced(domain: @domain,
|
||||
registrar: @domain.registrar,
|
||||
|
@ -34,4 +34,4 @@ class DomainDeleteMailerPreview < ActionMailer::Preview
|
|||
def expired
|
||||
DomainDeleteMailer.expired(@domain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
@domain.reload
|
||||
assert_equal template_name, @domain.template_name
|
||||
assert_equal @domain.notification_template, @domain.template_name
|
||||
end
|
||||
|
||||
def test_uses_legal_template_if_registrant_org
|
||||
|
@ -57,7 +57,23 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
@domain.reload
|
||||
assert_equal template_name, @domain.template_name
|
||||
assert_equal @domain.notification_template, @domain.template_name
|
||||
end
|
||||
|
||||
def test_uses_legal_template_if_invalid_email
|
||||
verification = @domain.contacts.first.email_verification
|
||||
verification.update(verified_at: Time.zone.now - 1.day, success: false)
|
||||
|
||||
assert_equal @domain.notification_template, 'invalid_email'
|
||||
|
||||
assert_emails 0 do
|
||||
visit edit_admin_domain_url(@domain)
|
||||
find(:css, '#soft_delete').set(true)
|
||||
click_link_or_button 'Force delete domain'
|
||||
end
|
||||
|
||||
@domain.reload
|
||||
assert_equal @domain.notification_template, @domain.template_name
|
||||
end
|
||||
|
||||
def test_allows_to_skip_notifying_registrant_and_admin_contacts_by_email
|
||||
|
@ -87,10 +103,4 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
|||
assert_no_button 'Schedule force delete'
|
||||
assert_no_link 'Schedule force delete'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def template_name
|
||||
@domain.registrant.org? ? 'legal_person' : 'private_person'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue