Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yulgolem committed Nov 5, 2020
1 parent 0116531 commit 454149a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/mailers/previews/domain_delete_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -34,4 +34,4 @@ def rejected
def expired
DomainDeleteMailer.expired(@domain)
end
end
end
26 changes: 18 additions & 8 deletions test/system/admin_area/domains/force_delete_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_notifies_registrant_and_admin_contacts_by_email_if_soft_delete
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
Expand All @@ -57,7 +57,23 @@ def test_uses_legal_template_if_registrant_org
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
Expand Down Expand Up @@ -87,10 +103,4 @@ def test_force_delete_procedure_cannot_be_scheduled_on_a_discarded_domain
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

0 comments on commit 454149a

Please sign in to comment.