Merge pull request #1149 from internetee/improve-registrant-change-mailer

Improve registrant change mailer
This commit is contained in:
Timo Võhmar 2019-04-09 17:18:46 +03:00 committed by GitHub
commit c192cc0538
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 104 additions and 446 deletions

View file

@ -0,0 +1,38 @@
class RegistrantChangeMailerPreview < ActionMailer::Preview
def initialize
@domain = Domain.first
@new_registrant = Registrant.where.not(email: nil, country_code: nil).first
super
end
def confirmation_request
RegistrantChangeMailer.confirmation_request(domain: @domain,
registrar: @domain.registrar,
current_registrant: @domain.registrant,
new_registrant: @new_registrant)
end
def notification
RegistrantChangeMailer.notification(domain: @domain,
registrar: @domain.registrar,
current_registrant: @domain.registrant,
new_registrant: @new_registrant)
end
def accepted
RegistrantChangeMailer.accepted(domain: @domain,
old_registrant: @domain.registrar)
end
def rejected
RegistrantChangeMailer.rejected(domain: @domain,
registrar: @domain.registrar,
registrant: @domain.registrant)
end
def expired
RegistrantChangeMailer.expired(domain: @domain,
registrar: @domain.registrar,
registrant: @domain.registrant)
end
end

View file

@ -12,10 +12,11 @@ class RegistrantChangeMailerTest < ActiveSupport::TestCase
assert_equal 'shop.test', @domain.name
assert_equal 'john@inbox.test', @domain.registrant.email
email = RegistrantChangeMailer.confirm(domain: @domain,
registrar: @domain.registrar,
current_registrant: @domain.registrant,
new_registrant: @domain.registrant).deliver_now
email = RegistrantChangeMailer.confirmation_request(domain: @domain,
registrar: @domain.registrar,
current_registrant: @domain.registrant,
new_registrant: @domain.registrant)
.deliver_now
assert_emails 1
assert_equal ['john@inbox.test'], email.to
@ -28,10 +29,10 @@ class RegistrantChangeMailerTest < ActiveSupport::TestCase
assert_equal 'shop.test', @domain.name
assert_equal 'william@inbox.test', new_registrant.email
email = RegistrantChangeMailer.notice(domain: @domain,
registrar: @domain.registrar,
current_registrant: @domain.registrant,
new_registrant: new_registrant).deliver_now
email = RegistrantChangeMailer.notification(domain: @domain,
registrar: @domain.registrar,
current_registrant: @domain.registrant,
new_registrant: new_registrant).deliver_now
assert_emails 1
assert_equal ['william@inbox.test'], email.to
@ -45,8 +46,8 @@ class RegistrantChangeMailerTest < ActiveSupport::TestCase
assert_equal 'john@inbox.test', @domain.registrant.email
assert_equal 'william@inbox.test', new_registrant.email
email = RegistrantChangeMailer.confirmed(domain: @domain,
old_registrant: new_registrant).deliver_now
email = RegistrantChangeMailer.accepted(domain: @domain,
old_registrant: new_registrant).deliver_now
assert_emails 1
assert_equal %w[john@inbox.test william@inbox.test], email.to