Fix existing tests

This commit is contained in:
Alex Sherman 2020-11-05 12:45:59 +05:00
parent 3ce0fc4a5c
commit 0116531786
4 changed files with 8 additions and 16 deletions

View file

@ -2,7 +2,6 @@ module Admin
class DomainsController < BaseController
before_action :set_domain, only: %i[show edit update keep]
authorize_resource
helper_method :force_delete_templates
def index
params[:q] ||= {}
@ -105,9 +104,5 @@ module Admin
params[:q][:valid_to_lteq] = ca_cache
end
def force_delete_templates
DomainDeleteMailer.force_delete_templates
end
end
end

View file

@ -1,8 +1,4 @@
class DomainDeleteMailer < ApplicationMailer
def self.force_delete_templates
%w[private_person legal_person]
end
def confirmation_request(domain:, registrar:, registrant:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)

View file

@ -20,7 +20,13 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
end
def notification_template
registrant.org? ? 'legal_person' : 'private_person'
if contact_emails_verification_failed.present?
'invalid_email'
elsif registrant.org?
'legal_person'
else
'private_person'
end
end
def force_delete_scheduled?

View file

@ -5,10 +5,6 @@ class DomainDeleteMailerTest < ActionMailer::TestCase
@domain = domains(:shop)
end
def test_force_delete_templates
assert_equal %w[private_person legal_person], DomainDeleteMailer.force_delete_templates
end
def test_delivers_confirmation_request_email
assert_equal 'shop.test', @domain.name
assert_equal 'john@inbox.test', @domain.registrant.email
@ -68,8 +64,7 @@ class DomainDeleteMailerTest < ActionMailer::TestCase
email = DomainDeleteMailer.forced(domain: @domain,
registrar: @domain.registrar,
registrant: @domain.registrant,
template_name: DomainDeleteMailer.force_delete_templates
.first).deliver_now
template_name: @domain.notification_template).deliver_now
assert_emails 1
assert_equal ['legal@registry.test'], email.from