mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
parent
962e98317d
commit
a6de3761c5
57 changed files with 238 additions and 203 deletions
18
app/mailers/delete_domain_mailer.rb
Normal file
18
app/mailers/delete_domain_mailer.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class DeleteDomainMailer < ApplicationMailer
|
||||||
|
include Que::Mailer
|
||||||
|
|
||||||
|
def pending(domain:, old_registrant:)
|
||||||
|
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||||
|
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||||
|
@verification_url = verification_url(domain)
|
||||||
|
|
||||||
|
subject = default_i18n_subject(domain_name: domain.name)
|
||||||
|
mail(to: old_registrant.email, subject: subject)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def verification_url(domain)
|
||||||
|
registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,21 +1,6 @@
|
||||||
class DomainMailer < ApplicationMailer
|
class DomainMailer < ApplicationMailer
|
||||||
include Que::Mailer
|
include Que::Mailer
|
||||||
|
|
||||||
def pending_update_request_for_old_registrant(domain:, registrant:)
|
|
||||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
|
||||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
|
||||||
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
|
|
||||||
@verification_url = registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token)
|
|
||||||
|
|
||||||
subject = default_i18n_subject(domain_name: domain.name)
|
|
||||||
mail(to: registrant.email, subject: subject)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_update_notification_for_new_registrant(params)
|
|
||||||
compose_from(params)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
||||||
@domain = Domain.find_by(id: domain_id)
|
@domain = Domain.find_by(id: domain_id)
|
||||||
return unless @domain
|
return unless @domain
|
||||||
|
@ -45,23 +30,6 @@ class DomainMailer < ApplicationMailer
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_update_rejected_notification_for_new_registrant(params)
|
|
||||||
compose_from(params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_update_expired_notification_for_new_registrant(params)
|
|
||||||
compose_from(params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_deleted(domain:, registrant:)
|
|
||||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
|
||||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
|
||||||
@verification_url = registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
|
|
||||||
|
|
||||||
subject = default_i18n_subject(domain_name: domain.name)
|
|
||||||
mail(to: registrant.email, subject: subject)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_delete_rejected_notification(domain_id, should_deliver)
|
def pending_delete_rejected_notification(domain_id, should_deliver)
|
||||||
@domain = Domain.find_by(id: domain_id)
|
@domain = Domain.find_by(id: domain_id)
|
||||||
return unless @domain
|
return unless @domain
|
||||||
|
|
45
app/mailers/registrant_change_mailer.rb
Normal file
45
app/mailers/registrant_change_mailer.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
class RegistrantChangeMailer < ApplicationMailer
|
||||||
|
include Que::Mailer
|
||||||
|
|
||||||
|
def confirmation(domain:, registrant:)
|
||||||
|
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||||
|
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||||
|
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
|
||||||
|
@verification_url = confirm_url(domain)
|
||||||
|
|
||||||
|
subject = default_i18n_subject(domain_name: domain.name)
|
||||||
|
mail(to: registrant.email, subject: subject)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending_update_notification_for_new_registrant(params)
|
||||||
|
compose_from(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
||||||
|
@domain = Domain.find_by(id: domain_id)
|
||||||
|
return unless @domain
|
||||||
|
return if delivery_off?(@domain, should_deliver)
|
||||||
|
|
||||||
|
@old_registrant = Registrant.find(old_registrant_id)
|
||||||
|
@new_registrant = Registrant.find(new_registrant_id)
|
||||||
|
|
||||||
|
return if whitelist_blocked?(@old_registrant.email)
|
||||||
|
mail(to: format(@old_registrant.email),
|
||||||
|
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
|
||||||
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending_update_rejected_notification_for_new_registrant(params)
|
||||||
|
compose_from(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending_update_expired_notification_for_new_registrant(params)
|
||||||
|
compose_from(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def confirm_url(domain)
|
||||||
|
registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token)
|
||||||
|
end
|
||||||
|
end
|
|
@ -379,6 +379,9 @@ class Domain < ActiveRecord::Base
|
||||||
new_registrant_email = registrant.email
|
new_registrant_email = registrant.email
|
||||||
new_registrant_name = registrant.name
|
new_registrant_name = registrant.name
|
||||||
|
|
||||||
|
current_registrant = Registrant.find(registrant_id_was)
|
||||||
|
RegistrantChangeMailer.confirmation(domain: self, current_registrant: current_registrant).deliver
|
||||||
|
|
||||||
send_mail :pending_update_request_for_old_registrant
|
send_mail :pending_update_request_for_old_registrant
|
||||||
send_mail :pending_update_notification_for_new_registrant
|
send_mail :pending_update_notification_for_new_registrant
|
||||||
|
|
||||||
|
@ -441,8 +444,8 @@ class Domain < ActiveRecord::Base
|
||||||
pending_delete_confirmation!
|
pending_delete_confirmation!
|
||||||
save(validate: false) # should check if this did succeed
|
save(validate: false) # should check if this did succeed
|
||||||
|
|
||||||
previous_registrant = Registrant.find(registrant_id_was)
|
old_registrant = Registrant.find(registrant_id_was)
|
||||||
DomainMailer.pending_deleted(domain: self, registrant: previous_registrant).deliver
|
DeleteDomainMailer.pending(domain: self, old_registrant: old_registrant).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancel_pending_delete
|
def cancel_pending_delete
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class DomainMailModel
|
class DomainMailModel
|
||||||
# Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later
|
# Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later
|
||||||
|
|
||||||
def initialize(domain)
|
def initialize(domain)
|
||||||
@domain = domain
|
@domain = domain
|
||||||
@params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id}
|
@params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id}
|
||||||
|
@ -15,13 +15,13 @@ class DomainMailModel
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_update_notification_for_new_registrant
|
def pending_update_notification_for_new_registrant
|
||||||
registrant # new registrant at this point
|
registrant # new registrant at this point
|
||||||
subject(:pending_update_notification_for_new_registrant_subject)
|
subject(:pending_update_notification_for_new_registrant_subject)
|
||||||
domain_info
|
domain_info
|
||||||
compose
|
compose
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def pending_update_rejected_notification_for_new_registrant
|
def pending_update_rejected_notification_for_new_registrant
|
||||||
registrant_pending
|
registrant_pending
|
||||||
subject(:pending_update_rejected_notification_for_new_registrant_subject)
|
subject(:pending_update_rejected_notification_for_new_registrant_subject)
|
||||||
|
@ -37,13 +37,6 @@ class DomainMailModel
|
||||||
compose
|
compose
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_deleted
|
|
||||||
registrant
|
|
||||||
subject(:domain_pending_deleted_subject)
|
|
||||||
confirm_delete
|
|
||||||
compose
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_delete_rejected_notification
|
def pending_delete_rejected_notification
|
||||||
registrant
|
registrant
|
||||||
subject(:pending_delete_rejected_notification_subject)
|
subject(:pending_delete_rejected_notification_subject)
|
||||||
|
@ -69,11 +62,11 @@ class DomainMailModel
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def registrant_old
|
def registrant_old
|
||||||
@params[:recipient] = format Registrant.find(@domain.registrant_id_was).email
|
@params[:recipient] = format Registrant.find(@domain.registrant_id_was).email
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrant
|
def registrant
|
||||||
@params[:recipient] = format @domain.registrant.email
|
@params[:recipient] = format @domain.registrant.email
|
||||||
end
|
end
|
||||||
|
@ -83,7 +76,7 @@ class DomainMailModel
|
||||||
@params[:new_registrant_name] = @domain.pending_json['new_registrant_name']
|
@params[:new_registrant_name] = @domain.pending_json['new_registrant_name']
|
||||||
@params[:old_registrant_name] = @domain.registrant.name
|
@params[:old_registrant_name] = @domain.registrant.name
|
||||||
end
|
end
|
||||||
|
|
||||||
# registrant and domain admin contacts
|
# registrant and domain admin contacts
|
||||||
def admins
|
def admins
|
||||||
emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) })
|
emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) })
|
||||||
|
@ -106,26 +99,22 @@ class DomainMailModel
|
||||||
def confirm_update
|
def confirm_update
|
||||||
verification_url('domain_update_confirms')
|
verification_url('domain_update_confirms')
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_delete
|
|
||||||
verification_url('domain_delete_confirms')
|
|
||||||
end
|
|
||||||
|
|
||||||
def compose
|
def compose
|
||||||
@params
|
@params
|
||||||
end
|
end
|
||||||
|
|
||||||
def verification_url(path)
|
def verification_url(path)
|
||||||
token = verification_token or return
|
token = verification_token or return
|
||||||
@params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}"
|
@params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def verification_token
|
def verification_token
|
||||||
return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank?
|
return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank?
|
||||||
return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank?
|
return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank?
|
||||||
@domain.registrant_verification_token
|
@domain.registrant_verification_token
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_info
|
def domain_info
|
||||||
[:name, :registrar_name,
|
[:name, :registrar_name,
|
||||||
:registrant_name, :registrant_ident, :registrant_email,
|
:registrant_name, :registrant_ident, :registrant_email,
|
||||||
|
@ -143,7 +132,7 @@ class DomainMailModel
|
||||||
warn_missing item
|
warn_missing item
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def warn_missing(item)
|
def warn_missing(item)
|
||||||
warn_not_delivered "#{item.to_s} is missing for #{@domain.name}"
|
warn_not_delivered "#{item.to_s} is missing for #{@domain.name}"
|
||||||
end
|
end
|
||||||
|
@ -154,6 +143,6 @@ class DomainMailModel
|
||||||
# Rails.logger.warn message
|
# Rails.logger.warn message
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ Tere
|
||||||
<br><br>
|
<br><br>
|
||||||
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
|
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
|
||||||
|
|
||||||
<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %>
|
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
|
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
|
||||||
|
@ -19,7 +19,7 @@ Hi,
|
||||||
<br><br>
|
<br><br>
|
||||||
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please contact your registrar:
|
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please contact your registrar:
|
||||||
|
|
||||||
<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %>
|
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
To confirm the update please visit this website, once again review the data and press approve:<br>
|
To confirm the update please visit this website, once again review the data and press approve:<br>
|
|
@ -2,7 +2,7 @@ Tere
|
||||||
|
|
||||||
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
|
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
|
||||||
|
|
||||||
<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %>
|
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
|
||||||
|
|
||||||
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
|
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ Hi,
|
||||||
|
|
||||||
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. In case of problems please contact your registrar:
|
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. In case of problems please contact your registrar:
|
||||||
|
|
||||||
<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %>
|
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
|
||||||
|
|
||||||
To confirm the update please visit this website, once again review the data and press approve:
|
To confirm the update please visit this website, once again review the data and press approve:
|
||||||
<%= @verification_url %>
|
<%= @verification_url %>
|
|
@ -16,7 +16,7 @@ Hi,
|
||||||
<br><br>
|
<br><br>
|
||||||
Domain registrant change request has been expired for the domain <%= @domain.name %>.
|
Domain registrant change request has been expired for the domain <%= @domain.name %>.
|
||||||
<br><br>
|
<br><br>
|
||||||
Please contact to your registrar if you have any questions:
|
Please contact to your registrar if you have any questions:
|
||||||
|
|
||||||
<%= render 'registrar.en.html', registrar: @registrar %>
|
<%= render 'registrar.en.html', registrar: @registrar %>
|
||||||
|
|
6
config/locales/mailers/delete_domain.en.yml
Normal file
6
config/locales/mailers/delete_domain.en.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
en:
|
||||||
|
domain_mailer:
|
||||||
|
expiration:
|
||||||
|
subject: The %{domain_name} domain has expired
|
||||||
|
force_delete:
|
||||||
|
subject: Kustutusmenetluse teade
|
|
@ -1,10 +1,4 @@
|
||||||
en:
|
en:
|
||||||
domain_mailer:
|
delete_domain_mailer:
|
||||||
pending_update_request_for_old_registrant:
|
pending:
|
||||||
subject: Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks / Application for approval for registrant change of %{domain_name}
|
|
||||||
expiration:
|
|
||||||
subject: The %{domain_name} domain has expired
|
|
||||||
force_delete:
|
|
||||||
subject: Kustutusmenetluse teade
|
|
||||||
pending_deleted:
|
|
||||||
subject: Kinnitustaotlus domeeni %{domain_name} kustutamiseks .ee registrist / Application for approval for deletion of %{domain_name}
|
subject: Kinnitustaotlus domeeni %{domain_name} kustutamiseks .ee registrist / Application for approval for deletion of %{domain_name}
|
||||||
|
|
4
config/locales/mailers/registrant_change.en.yml
Normal file
4
config/locales/mailers/registrant_change.en.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
en:
|
||||||
|
registrant_change_mailer:
|
||||||
|
confirmation:
|
||||||
|
subject: Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks / Application for approval for registrant change of %{domain_name}
|
42
spec/mailers/delete_domain_mailer_spec.rb
Normal file
42
spec/mailers/delete_domain_mailer_spec.rb
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe DeleteDomainMailer do
|
||||||
|
describe '#pending' do
|
||||||
|
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||||
|
let(:old_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
|
||||||
|
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||||
|
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||||
|
subject(:message) { described_class.pending(domain: domain, old_registrant: old_registrant) }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
||||||
|
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has sender' do
|
||||||
|
expect(message.from).to eq(['noreply@internet.ee'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has old registrant email as a recipient' do
|
||||||
|
expect(message.to).to match_array(['registrant@test.com'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has subject' do
|
||||||
|
subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \
|
||||||
|
' / Application for approval for deletion of test.com'
|
||||||
|
|
||||||
|
expect(message.subject).to eq(subject)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has confirmation url' do
|
||||||
|
allow(domain).to receive(:id).and_return(1)
|
||||||
|
expect(domain).to receive(:registrant_verification_token).and_return('test')
|
||||||
|
url = registrant_domain_delete_confirm_url(domain, token: 'test')
|
||||||
|
expect(message.body.parts.first.decoded).to include(url)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sends message' do
|
||||||
|
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,88 +1,6 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe DomainMailer do
|
RSpec.describe DomainMailer do
|
||||||
describe '#pending_update_request_for_old_registrant' do
|
|
||||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
|
||||||
let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
|
|
||||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
|
||||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
|
||||||
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
|
||||||
subject(:message) { described_class.pending_update_request_for_old_registrant(domain: domain,
|
|
||||||
registrant: registrant,
|
|
||||||
) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
|
||||||
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
|
||||||
expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has sender' do
|
|
||||||
expect(message.from).to eq(['noreply@internet.ee'])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has registrant email as a recipient' do
|
|
||||||
expect(message.to).to match_array(['registrant@test.com'])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has subject' do
|
|
||||||
subject = 'Kinnitustaotlus domeeni test.com registreerija vahetuseks' \
|
|
||||||
' / Application for approval for registrant change of test.com'
|
|
||||||
|
|
||||||
expect(message.subject).to eq(subject)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has confirmation url' do
|
|
||||||
allow(domain).to receive(:id).and_return(1)
|
|
||||||
expect(domain).to receive(:registrant_verification_token).and_return('test')
|
|
||||||
url = registrant_domain_update_confirm_url(domain, token: 'test')
|
|
||||||
expect(message.body.parts.first.decoded).to include(url)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends message' do
|
|
||||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#pending_deleted' do
|
|
||||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
|
||||||
let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
|
|
||||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
|
||||||
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
|
||||||
subject(:message) { described_class.pending_deleted(domain: domain, registrant: registrant) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
|
||||||
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has sender' do
|
|
||||||
expect(message.from).to eq(['noreply@internet.ee'])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has registrant email as a recipient' do
|
|
||||||
expect(message.to).to match_array(['registrant@test.com'])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has subject' do
|
|
||||||
subject = 'Kinnitustaotlus domeeni test.com kustutamiseks .ee registrist' \
|
|
||||||
' / Application for approval for deletion of test.com'
|
|
||||||
|
|
||||||
expect(message.subject).to eq(subject)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has confirmation url' do
|
|
||||||
allow(domain).to receive(:id).and_return(1)
|
|
||||||
expect(domain).to receive(:registrant_verification_token).and_return('test')
|
|
||||||
url = registrant_domain_delete_confirm_url(domain, token: 'test')
|
|
||||||
expect(message.body.parts.first.decoded).to include(url)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends message' do
|
|
||||||
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#force_delete' do
|
describe '#force_delete' do
|
||||||
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||||
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||||
|
|
46
spec/mailers/registrant_change_mailer_spec.rb
Normal file
46
spec/mailers/registrant_change_mailer_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe RegistrantChangeMailer do
|
||||||
|
describe '#confirmation' do
|
||||||
|
let(:domain) { instance_spy(Domain, name: 'test.com') }
|
||||||
|
let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
|
||||||
|
let(:domain_presenter) { instance_spy(DomainPresenter) }
|
||||||
|
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
|
||||||
|
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
|
||||||
|
subject(:message) { described_class.confirmation(domain: domain,
|
||||||
|
registrant: registrant,
|
||||||
|
) }
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
|
||||||
|
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
|
||||||
|
expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has sender' do
|
||||||
|
expect(message.from).to eq(['noreply@internet.ee'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has registrant email as a recipient' do
|
||||||
|
expect(message.to).to match_array(['registrant@test.com'])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has subject' do
|
||||||
|
subject = 'Kinnitustaotlus domeeni test.com registreerija vahetuseks' \
|
||||||
|
' / Application for approval for registrant change of test.com'
|
||||||
|
|
||||||
|
expect(message.subject).to eq(subject)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has confirmation url' do
|
||||||
|
allow(domain).to receive(:id).and_return(1)
|
||||||
|
expect(domain).to receive(:registrant_verification_token).and_return('test')
|
||||||
|
url = registrant_domain_update_confirm_url(domain, token: 'test')
|
||||||
|
expect(message.body.parts.first.decoded).to include(url)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sends message' do
|
||||||
|
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -822,17 +822,19 @@ RSpec.describe Domain, db: false do
|
||||||
|
|
||||||
describe '#pending_delete!' do
|
describe '#pending_delete!' do
|
||||||
let(:domain) { described_class.new }
|
let(:domain) { described_class.new }
|
||||||
let(:previous_registrant) { instance_double(Registrant) }
|
let(:old_registrant) { instance_double(Registrant) }
|
||||||
let(:message) { instance_double(Mail::Message) }
|
let(:message) { instance_double(Mail::Message) }
|
||||||
|
|
||||||
before :example do
|
before :example do
|
||||||
expect(Registrant).to receive(:find).and_return(previous_registrant)
|
expect(Registrant).to receive(:find).and_return(old_registrant)
|
||||||
allow(domain).to receive(:registrant_verification_asked?).and_return(true)
|
allow(domain).to receive(:registrant_verification_asked?).and_return(true)
|
||||||
allow(domain).to receive(:save)
|
allow(domain).to receive(:save)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends notification email' do
|
it 'sends notification email' do
|
||||||
expect(DomainMailer).to receive(:pending_deleted).with(domain: domain, registrant: previous_registrant).and_return(message)
|
expect(DeleteDomainMailer).to receive(:pending)
|
||||||
|
.with(domain: domain, old_registrant: old_registrant)
|
||||||
|
.and_return(message)
|
||||||
expect(message).to receive(:deliver)
|
expect(message).to receive(:deliver)
|
||||||
domain.pending_delete!
|
domain.pending_delete!
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
require_relative 'pending_shared'
|
||||||
|
|
||||||
|
RSpec.describe 'mailers/delete_domain_mailer/pending.html.erb' do
|
||||||
|
before :example do
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'delete domain mailer pending'
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
require_relative 'pending_shared'
|
||||||
|
|
||||||
|
RSpec.describe 'mailers/delete_domain_mailer/pending.text.erb' do
|
||||||
|
before :example do
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'delete domain mailer pending'
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.shared_examples 'domain mailer pending deleted' do
|
RSpec.shared_examples 'delete domain mailer pending' do
|
||||||
let(:domain) { instance_spy(DomainPresenter) }
|
let(:domain) { instance_spy(DomainPresenter) }
|
||||||
let(:lang_count) { 2 }
|
let(:lang_count) { 2 }
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require_relative 'pending_deleted_shared'
|
|
||||||
|
|
||||||
RSpec.describe 'mailers/domain_mailer/pending_deleted.html.erb' do
|
|
||||||
before :example do
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.et.html' => 'test registrar estonian'
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.en.html' => 'test registrar english'
|
|
||||||
end
|
|
||||||
|
|
||||||
include_examples 'domain mailer pending deleted'
|
|
||||||
end
|
|
|
@ -1,11 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require_relative 'pending_deleted_shared'
|
|
||||||
|
|
||||||
RSpec.describe 'mailers/domain_mailer/pending_deleted.text.erb' do
|
|
||||||
before :example do
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.et.text' => 'test registrar estonian'
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.en.text' => 'test registrar english'
|
|
||||||
end
|
|
||||||
|
|
||||||
include_examples 'domain mailer pending deleted'
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require_relative 'pending_update_request_for_old_registrant_shared'
|
|
||||||
|
|
||||||
RSpec.describe 'mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb' do
|
|
||||||
before :example do
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.et.html' => 'test registrar estonian'
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.en.html' => 'test registrar english'
|
|
||||||
stub_template 'mailers/domain_mailer/registrant/_registrant.et.html' => 'test new registrant estonian'
|
|
||||||
stub_template 'mailers/domain_mailer/registrant/_registrant.en.html' => 'test new registrant english'
|
|
||||||
end
|
|
||||||
|
|
||||||
include_examples 'domain mailer pending update request for old registrant'
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
require_relative 'pending_update_request_for_old_registrant_shared'
|
|
||||||
|
|
||||||
RSpec.describe 'mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb' do
|
|
||||||
before :example do
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.et.text' => 'test registrar estonian'
|
|
||||||
stub_template 'mailers/domain_mailer/registrar/_registrar.en.text' => 'test registrar english'
|
|
||||||
stub_template 'mailers/domain_mailer/registrant/_registrant.et.text' => 'test new registrant estonian'
|
|
||||||
stub_template 'mailers/domain_mailer/registrant/_registrant.en.text' => 'test new registrant english'
|
|
||||||
end
|
|
||||||
|
|
||||||
include_examples 'domain mailer pending update request for old registrant'
|
|
||||||
end
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
require_relative 'confirmation_shared'
|
||||||
|
|
||||||
|
RSpec.describe 'mailers/registrant_change_mailer/confirmation.html.erb' do
|
||||||
|
before :example do
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
|
||||||
|
stub_template 'mailers/shared/registrant/_registrant.et.html' => 'test new registrant estonian'
|
||||||
|
stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english'
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'domain mailer pending update request for old registrant'
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
require_relative 'confirmation_shared'
|
||||||
|
|
||||||
|
RSpec.describe 'mailers/registrant_change_mailer/confirmation.text.erb' do
|
||||||
|
before :example do
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
|
||||||
|
stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
|
||||||
|
stub_template 'mailers/shared/registrant/_registrant.et.text' => 'test new registrant estonian'
|
||||||
|
stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english'
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'domain mailer pending update request for old registrant'
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue