Refactor domain mailer views

#180
This commit is contained in:
Artur Beljajev 2016-11-14 01:35:47 +02:00
parent a6de3761c5
commit 2c3dbc6e32
31 changed files with 361 additions and 153 deletions

View file

@ -16,7 +16,9 @@ class DomainUpdateConfirmJob < Que::Job
domain.clean_pendings! domain.clean_pendings!
raise_errors!(domain) raise_errors!(domain)
when RegistrantVerification::REJECTED when RegistrantVerification::REJECTED
domain.send_mail :pending_update_rejected_notification_for_new_registrant RegistrantChangeMailer.rejected(domain: domain, registrar: domain.registrar, registrant: domain.registrant)
.deliver
domain.poll_message!(:poll_pending_update_rejected_by_registrant) domain.poll_message!(:poll_pending_update_rejected_by_registrant)
domain.clean_pendings_lowlevel domain.clean_pendings_lowlevel
end end

View file

View file

@ -1,36 +1,34 @@
class RegistrantChangeMailer < ApplicationMailer class RegistrantChangeMailer < ApplicationMailer
include Que::Mailer include Que::Mailer
def confirmation(domain:, registrant:) def confirm(domain:, registrar:, current_registrant:, new_registrant:)
@domain = DomainPresenter.new(domain: domain, view: view_context) @domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context) @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context) @new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
@verification_url = confirm_url(domain) @confirm_url = confirm_url(domain)
subject = default_i18n_subject(domain_name: domain.name) subject = default_i18n_subject(domain_name: domain.name)
mail(to: registrant.email, subject: subject) mail(to: current_registrant.email, subject: subject)
end end
def pending_update_notification_for_new_registrant(params) def notice(domain:, registrar:, current_registrant:, new_registrant:)
compose_from(params) @domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@current_registrant = RegistrantPresenter.new(registrant: current_registrant, view: view_context)
@new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
@confirm_url = confirm_url(domain)
subject = default_i18n_subject(domain_name: domain.name)
mail(to: new_registrant.email, subject: subject)
end end
def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver) def rejected(domain:, registrar:, registrant:)
@domain = Domain.find_by(id: domain_id) @domain = DomainPresenter.new(domain: domain, view: view_context)
return unless @domain @registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
return if delivery_off?(@domain, should_deliver) @registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
@old_registrant = Registrant.find(old_registrant_id) subject = default_i18n_subject(domain_name: domain.name)
@new_registrant = Registrant.find(new_registrant_id) mail(to: domain.new_registrant_email, subject: subject)
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 end
def pending_update_expired_notification_for_new_registrant(params) def pending_update_expired_notification_for_new_registrant(params)

View file

@ -380,12 +380,12 @@ class Domain < ActiveRecord::Base
new_registrant_name = registrant.name new_registrant_name = registrant.name
current_registrant = Registrant.find(registrant_id_was) current_registrant = Registrant.find(registrant_id_was)
RegistrantChangeMailer.confirmation(domain: self, current_registrant: current_registrant).deliver RegistrantChangeMailer.confirm(domain: self, registrar: registrar, current_registrant: current_registrant,
new_registrant: registrant).deliver
RegistrantChangeMailer.notice(domain: self, registrar: registrar, current_registrant: current_registrant,
new_registrant: registrant).deliver
send_mail :pending_update_request_for_old_registrant reload
send_mail :pending_update_notification_for_new_registrant
reload # revert back to original
self.pending_json = pending_json_cache self.pending_json = pending_json_cache
self.registrant_verification_token = token self.registrant_verification_token = token
@ -397,8 +397,8 @@ class Domain < ActiveRecord::Base
pending_json['new_registrant_name'] = new_registrant_name pending_json['new_registrant_name'] = new_registrant_name
# This pending_update! method is triggered by before_update # This pending_update! method is triggered by before_update
# Note, all before_save callbacks are excecuted before before_update, # Note, all before_save callbacks are executed before before_update,
# thus automatic statuses has already excectued by this point # thus automatic statuses has already executed by this point
# and we need to trigger automatic statuses manually (second time). # and we need to trigger automatic statuses manually (second time).
manage_automatic_statuses manage_automatic_statuses
end end
@ -741,6 +741,10 @@ class Domain < ActiveRecord::Base
admin_contact_emails << registrant_email admin_contact_emails << registrant_email
end end
def new_registrant_email
pending_json['new_registrant_email']
end
def self.to_csv def self.to_csv
CSV.generate do |csv| CSV.generate do |csv|
csv << column_names csv << column_names

View file

@ -6,30 +6,6 @@ class DomainMailModel
@params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id} @params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id}
end end
def pending_update_request_for_old_registrant
registrant_old
subject(:pending_update_request_for_old_registrant_subject)
confirm_update
domain_info
compose
end
def pending_update_notification_for_new_registrant
registrant # new registrant at this point
subject(:pending_update_notification_for_new_registrant_subject)
domain_info
compose
end
def pending_update_rejected_notification_for_new_registrant
registrant_pending
subject(:pending_update_rejected_notification_for_new_registrant_subject)
@params[:deliver_emails] = true # triggered from que
@params[:registrar_name] = @domain.registrar.name
compose
end
def pending_update_expired_notification_for_new_registrant def pending_update_expired_notification_for_new_registrant
registrant_pending registrant_pending
subject(:pending_update_expired_notification_for_new_registrant_subject) subject(:pending_update_expired_notification_for_new_registrant_subject)

View file

@ -21,7 +21,7 @@ Registrikood: <b><%= @registrant.ident %></b></p>
<p>Lisak&uuml;simuste korral v&otilde;tke palun &uuml;hendust oma registripidajaga:</p> <p>Lisak&uuml;simuste korral v&otilde;tke palun &uuml;hendust oma registripidajaga:</p>
<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<hr> <hr>
@ -42,7 +42,7 @@ Registry code: <b><%= @registrant.ident %></b></p>
<p>Should you have additional questions, please contact your registrar:</p> <p>Should you have additional questions, please contact your registrar:</p>
<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<hr> <hr>
@ -63,7 +63,7 @@ Registry code: <b><%= @registrant.ident %></b></p>
<p>Просим обратиться к своему регистратору:</p> <p>Просим обратиться к своему регистратору:</p>
<%= render 'mailers/domain_mailer/registrar/registrar.ru.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %>
<br /><br /> <br /><br />

View file

@ -15,7 +15,7 @@ Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.nam
Lisaküsimuste korral võtke palun ühendust oma registripidajaga: Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
@ -36,7 +36,7 @@ If the transfer has not been made in 30 days, the domain <%= @domain.name %> wil
Should you have additional questions, please contact your registrar: Should you have additional questions, please contact your registrar:
<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
Уважаемое контактное лицо домена <%= @domain.name %> Уважаемое контактное лицо домена <%= @domain.name %>
@ -56,7 +56,7 @@ EIS стало известно, что юридическое лицо с ре
Просим обратиться к своему регистратору: Просим обратиться к своему регистратору:
<%= render 'mailers/domain_mailer/registrar/registrar.ru.text', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.ru.text', registrar: @registrar %>
Lugupidamisega, Lugupidamisega,

View file

@ -2,17 +2,17 @@ Tere
<br><br> <br><br>
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. 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>
Uue registreerija andmed:<br> Uue registreerija andmed:<br>
<%= render 'mailers/domain_mailer/registrant/registrant.et.html', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %>
<br><br> <br><br>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka. Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka.
<br><br> <br><br>
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:<br> Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:<br>
<%= link_to @verification_url, @verification_url %> <%= link_to @confirm_url, @confirm_url %>
<br><br> <br><br>
Lugupidamisega<br> Lugupidamisega<br>
Eesti Interneti Sihtasutus Eesti Interneti Sihtasutus
@ -23,16 +23,16 @@ Hi,
<br><br> <br><br>
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar: Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to 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>
New registrant:<br> New registrant:<br>
<%= render 'mailers/domain_mailer/registrant/registrant.en.html', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %>
<br><br> <br><br>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.
<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>
<%= link_to @verification_url, @verification_url %> <%= link_to @confirm_url, @confirm_url %>
<br><br> <br><br>
Best Regards,<br> Best Regards,<br>
Estonian Internet Foundation Estonian Internet Foundation

View file

@ -2,14 +2,14 @@ Tere
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. 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 %>
Uue registreerija andmed: Uue registreerija andmed:
<%= render 'mailers/domain_mailer/registrant/registrant.et.text', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %>
Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka. Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ei kinnita või tagasi lükka.
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:
<%= @verification_url %> <%= @confirm_url %>
Lugupidamisega Lugupidamisega
Eesti Interneti Sihtasutus Eesti Interneti Sihtasutus
@ -20,14 +20,14 @@ Hi,
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar: Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. In case of problems please turn to your registrar:
<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
New registrant: New registrant:
<%= render 'mailers/domain_mailer/registrant/registrant.en.text', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %>
The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.
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 %> <%= @confirm_url %>
Best Regards, Best Regards,
Estonian Internet Foundation Estonian Internet Foundation

View file

@ -4,11 +4,11 @@ Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %
<br><br> <br><br>
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= render 'registrar.et.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<br><br> <br><br>
Uue registreerija andmed:<br> Uue registreerija andmed:<br>
<%= render 'registrant.et.html', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.et.html', registrant: @new_registrant %>
<br><br> <br><br>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
<br><br> <br><br>
@ -25,11 +25,11 @@ Registrant change process for the domain <%= @domain.name %> has been started.
<br><br> <br><br>
Please verify the details of the following change request. In case of problems contact your registrar: Please verify the details of the following change request. In case of problems contact your registrar:
<%= render 'registrar.en.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<br><br> <br><br>
New registrant:<br> New registrant:<br>
<%= render 'registrant.en.html', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.en.html', registrant: @new_registrant %>
<br><br> <br><br>
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it. The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.
<br><br> <br><br>

View file

@ -4,10 +4,10 @@ Registripidaja <%= @registrar.name %> vahendusel on algatatud <%= @domain.name %
Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole: Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= render 'registrar.et.text', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Uue registreerija andmed: Uue registreerija andmed:
<%= render 'registrant.et.text', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.et.text', registrant: @new_registrant %>
Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @current_registrant.name %> omanikuvahetuse tähtaegselt kinnitab.
@ -24,10 +24,10 @@ Registrant change process for the domain <%= @domain.name %> has been started.
Please verify the details of the following change request. In case of problems contact your registrar: Please verify the details of the following change request. In case of problems contact your registrar:
<%= render 'registrar.en.text', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
New registrant: New registrant:
<%= render 'registrant.en.text', registrant: @new_registrant %> <%= render 'mailers/shared/registrant/registrant.en.text', registrant: @new_registrant %>
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it. The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.

View file

@ -1,23 +0,0 @@
Tere
Domeeni <%= @domain.name %> registreerija <%= @current_registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Küsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'registrar.et.text', registrar: @registrar %>
Lugupidamisega
Eesti Interneti Sihtasutus
--------------------------------------
Hi,
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @current_registrant.name %>.
Please contact your registrar if you have any questions:
<%= render 'registrar.en.text', registrar: @registrar %>
Best Regards,
Estonian Internet Foundation

View file

@ -1,10 +1,10 @@
Tere Tere
<br><br> <br><br>
Domeeni <%= @domain.name %> registreerija <%= @current_registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
<br><br> <br><br>
Küsimuste korral võtke palun ühendust oma registripidajaga: Küsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'registrar.et.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
<br><br> <br><br>
Lugupidamisega<br> Lugupidamisega<br>
@ -14,11 +14,11 @@ Eesti Interneti Sihtasutus
<br><br> <br><br>
Hi, Hi,
<br><br> <br><br>
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @current_registrant.name %>. Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>.
<br><br> <br><br>
Please contact your registrar if you have any questions: Please contact your registrar if you have any questions:
<%= render 'registrar.en.html', registrar: @registrar %> <%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
<br><br> <br><br>
Best Regards,<br> Best Regards,<br>

View file

@ -0,0 +1,23 @@
Tere
Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni registreerija vahetamise taotluse tagasi lükanud.
Küsimuste korral võtke palun ühendust oma registripidajaga:
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
Lugupidamisega
Eesti Interneti Sihtasutus
--------------------------------------
Hi,
Registrant change for the domain <%= @domain.name %> was rejected by the registrant <%= @registrant.name %>.
Please contact your registrar if you have any questions:
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
Best Regards,
Estonian Internet Foundation

View file

@ -796,8 +796,6 @@ en:
unimplemented_object_service: 'Unimplemented object service' unimplemented_object_service: 'Unimplemented object service'
contact_email_update_subject: 'Teie domeenide kontakt epostiaadress on muutunud / Contact e-mail addresses of your domains have changed' contact_email_update_subject: 'Teie domeenide kontakt epostiaadress on muutunud / Contact e-mail addresses of your domains have changed'
object_status_prohibits_operation: 'Object status prohibits operation' object_status_prohibits_operation: 'Object status prohibits operation'
pending_update_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetus protseduur on algatatud / %{name} registrant change"
pending_update_rejected_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus tagasi lükatud / %{name} registrant change declined"
pending_update_expired_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus on tühistatud / %{name} registrant change cancelled" pending_update_expired_notification_for_new_registrant_subject: "Domeeni %{name} registreerija vahetuse taotlus on tühistatud / %{name} registrant change cancelled"
registrant_updated_notification_for_new_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.' registrant_updated_notification_for_new_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'
registrant_updated_notification_for_old_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.' registrant_updated_notification_for_old_registrant_subject: 'Domeeni %{name} registreerija vahetus teostatud / Registrant change of %{name} has been finished.'

View file

@ -1,4 +1,8 @@
en: en:
registrant_change_mailer: registrant_change_mailer:
confirmation: confirm:
subject: Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks / Application for approval for registrant change of %{domain_name} subject: Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks / Application for approval for registrant change of %{domain_name}
notice:
subject: Domeeni %{domain_name} registreerija vahetus protseduur on algatatud / %{domain_name} registrant change
rejected:
subject: Domeeni %{domain_name} registreerija vahetuse taotlus tagasi lükatud / %{domain_name} registrant change declined

View file

@ -1,27 +1,33 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe RegistrantChangeMailer do RSpec.describe RegistrantChangeMailer do
describe '#confirmation' do describe '#confirm' do
let(:domain) { instance_spy(Domain, name: 'test.com') } let(:domain) { instance_spy(Domain, name: 'test.com') }
let(:registrant) { instance_spy(Registrant, email: 'registrant@test.com') } let(:registrar) { instance_spy(Registrar) }
let(:current_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
let(:new_registrant) { instance_spy(Registrant) }
let(:domain_presenter) { instance_spy(DomainPresenter) } let(:domain_presenter) { instance_spy(DomainPresenter) }
let(:registrar_presenter) { instance_spy(RegistrarPresenter) } let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
let(:registrant_presenter) { instance_spy(RegistrantPresenter) } let(:new_registrant_presenter) { instance_spy(RegistrantPresenter) }
subject(:message) { described_class.confirmation(domain: domain,
registrant: registrant, subject(:message) { described_class.confirm(domain: domain,
) } registrar: registrar,
current_registrant: current_registrant,
new_registrant: new_registrant)
}
before :example do before :example do
expect(DomainPresenter).to receive(:new).and_return(domain_presenter) expect(DomainPresenter).to receive(:new).and_return(domain_presenter)
expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter) expect(RegistrarPresenter).to receive(:new).and_return(registrar_presenter)
expect(RegistrantPresenter).to receive(:new).and_return(registrant_presenter) expect(RegistrantPresenter).to receive(:new).and_return(new_registrant_presenter)
end end
it 'has sender' do it 'has sender' do
expect(message.from).to eq(['noreply@internet.ee']) expect(message.from).to eq(['noreply@internet.ee'])
end end
it 'has registrant email as a recipient' do it 'has current registrant\s email as a recipient' do
expect(message.to).to match_array(['registrant@test.com']) expect(message.to).to match_array(['registrant@test.com'])
end end
@ -43,4 +49,88 @@ RSpec.describe RegistrantChangeMailer do
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1) expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
end end
end end
describe '#notice' do
let(:domain) { instance_spy(Domain, name: 'test.com') }
let(:registrar) { instance_spy(Registrar) }
let(:current_registrant) { instance_spy(Registrant) }
let(:new_registrant) { instance_spy(Registrant, email: 'registrant@test.com') }
let(:domain_presenter) { instance_spy(DomainPresenter) }
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
let(:current_registrant_presenter) { instance_spy(RegistrantPresenter) }
let(:new_registrant_presenter) { instance_spy(RegistrantPresenter) }
subject(:message) { described_class.notice(domain: domain,
registrar: registrar,
current_registrant: current_registrant,
new_registrant: new_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).with(registrant: current_registrant, view: anything).and_return(current_registrant_presenter)
expect(RegistrantPresenter).to receive(:new).with(registrant: new_registrant, view: anything).and_return(new_registrant_presenter)
end
it 'has sender' do
expect(message.from).to eq(['noreply@internet.ee'])
end
it 'has new registrant\s email as a recipient' do
expect(message.to).to match_array(['registrant@test.com'])
end
it 'has subject' do
subject = 'Domeeni test.com registreerija vahetus protseduur on algatatud' \
' / test.com registrant change'
expect(message.subject).to eq(subject)
end
it 'sends message' do
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
describe '#rejected' do
let(:domain) { instance_spy(Domain, name: 'test.com', new_registrant_email: 'new.registrant@test.com') }
let(:registrar) { instance_spy(Registrar) }
let(:registrant) { instance_spy(Registrant) }
let(:domain_presenter) { instance_spy(DomainPresenter) }
let(:registrar_presenter) { instance_spy(RegistrarPresenter) }
let(:registrant_presenter) { instance_spy(RegistrantPresenter) }
subject(:message) { described_class.rejected(domain: domain,
registrar: registrar,
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 new registrant\s email as a recipient' do
expect(message.to).to match_array(['new.registrant@test.com'])
end
it 'has subject' do
subject = 'Domeeni test.com registreerija vahetuse taotlus tagasi lükatud' \
' / test.com registrant change declined'
expect(message.subject).to eq(subject)
end
it 'sends message' do
expect { message.deliver! }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
end
end end

View file

@ -891,4 +891,52 @@ RSpec.describe Domain, db: false do
expect(described_class.delete_candidates.ids).to eq([1]) expect(described_class.delete_candidates.ids).to eq([1])
end end
end end
describe '#pending_update!', db: false do
let(:domain) { described_class.new }
let(:current_registrant) { FactoryGirl.build_stubbed(:registrant) }
let(:new_registrant) { FactoryGirl.build_stubbed(:registrant) }
let(:message) { instance_double(Mail::Message) }
before :example do
expect(Registrant).to receive(:find).and_return(current_registrant)
expect(domain).to receive_messages(
reload: true,
pending_update?: false,
registrant_verification_asked?: true,
registrar: 'registrar',
registrant: new_registrant,
manage_automatic_statuses: true
)
end
it 'sends confirm and notice emails' do
allow(RegistrantChangeMailer).to receive(:notice).and_return(message)
expect(RegistrantChangeMailer).to receive(:confirm)
.with(
domain: domain,
registrar: 'registrar',
current_registrant: current_registrant,
new_registrant: new_registrant)
.and_return(message)
expect(RegistrantChangeMailer).to receive(:notice)
.with(
domain: domain,
registrar: 'registrar',
current_registrant: current_registrant,
new_registrant: new_registrant)
.and_return(message)
expect(message).to receive(:deliver).exactly(2).times
domain.pending_update!
end
end
describe '#new_registrant_email' do
let(:domain) { described_class.new(pending_json: { new_registrant_email: 'test@test.com' }) }
it 'returns new registrant\'s email' do
expect(domain.new_registrant_email).to eq('test@test.com')
end
end
end end

View file

@ -3,9 +3,9 @@ require_relative 'force_delete_shared'
RSpec.describe 'mailers/domain_mailer/force_delete.html.erb' do RSpec.describe 'mailers/domain_mailer/force_delete.html.erb' do
before :example do before :example do
stub_template 'mailers/domain_mailer/registrar/_registrar.et.html' => 'test registrar estonian' stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian'
stub_template 'mailers/domain_mailer/registrar/_registrar.en.html' => 'test registrar english' stub_template 'mailers/shared/registrar/_registrar.en.html' => 'test registrar english'
stub_template 'mailers/domain_mailer/registrar/_registrar.ru.html' => 'test registrar russian' stub_template 'mailers/shared/registrar/_registrar.ru.html' => 'test registrar russian'
end end
include_examples 'domain mailer force delete' include_examples 'domain mailer force delete'

View file

@ -3,9 +3,9 @@ require_relative 'force_delete_shared'
RSpec.describe 'mailers/domain_mailer/force_delete.text.erb' do RSpec.describe 'mailers/domain_mailer/force_delete.text.erb' do
before :example do before :example do
stub_template 'mailers/domain_mailer/registrar/_registrar.et.text' => 'test registrar estonian' stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian'
stub_template 'mailers/domain_mailer/registrar/_registrar.en.text' => 'test registrar english' stub_template 'mailers/shared/registrar/_registrar.en.text' => 'test registrar english'
stub_template 'mailers/domain_mailer/registrar/_registrar.ru.text' => 'test registrar russian' stub_template 'mailers/shared/registrar/_registrar.ru.text' => 'test registrar russian'
end end
include_examples 'domain mailer force delete' include_examples 'domain mailer force delete'

View file

@ -1,7 +1,7 @@
require 'rails_helper' require 'rails_helper'
require_relative 'confirmation_shared' require_relative 'confirm_shared'
RSpec.describe 'mailers/registrant_change_mailer/confirmation.html.erb' do RSpec.describe 'mailers/registrant_change_mailer/confirm.html.erb' do
before :example do before :example do
stub_template 'mailers/shared/registrar/_registrar.et.html' => 'test registrar estonian' 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/registrar/_registrar.en.html' => 'test registrar english'
@ -9,5 +9,5 @@ RSpec.describe 'mailers/registrant_change_mailer/confirmation.html.erb' do
stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english' stub_template 'mailers/shared/registrant/_registrant.en.html' => 'test new registrant english'
end end
include_examples 'domain mailer pending update request for old registrant' include_examples 'registrant change mailer confirm'
end end

View file

@ -1,7 +1,7 @@
require 'rails_helper' require 'rails_helper'
require_relative 'confirmation_shared' require_relative 'confirm_shared'
RSpec.describe 'mailers/registrant_change_mailer/confirmation.text.erb' do RSpec.describe 'mailers/registrant_change_mailer/confirm.text.erb' do
before :example do before :example do
stub_template 'mailers/shared/registrar/_registrar.et.text' => 'test registrar estonian' 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/registrar/_registrar.en.text' => 'test registrar english'
@ -9,5 +9,5 @@ RSpec.describe 'mailers/registrant_change_mailer/confirmation.text.erb' do
stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english' stub_template 'mailers/shared/registrant/_registrant.en.text' => 'test new registrant english'
end end
include_examples 'domain mailer pending update request for old registrant' include_examples 'registrant change mailer confirm'
end end

View file

@ -1,6 +1,6 @@
require 'rails_helper' require 'rails_helper'
RSpec.shared_examples 'domain mailer pending update request for old registrant' do RSpec.shared_examples 'registrant change mailer confirm' do
let(:domain) { instance_spy(DomainPresenter) } let(:domain) { instance_spy(DomainPresenter) }
let(:lang_count) { 2 } let(:lang_count) { 2 }
@ -8,7 +8,7 @@ RSpec.shared_examples 'domain mailer pending update request for old registrant'
assign(:domain, domain) assign(:domain, domain)
assign(:registrar, nil) assign(:registrar, nil)
assign(:new_registrant, nil) assign(:new_registrant, nil)
assign(:verification_url, 'test verification url') assign(:confirm_url, 'test confirm url')
end end
it 'has registrar info in estonian' do it 'has registrar info in estonian' do
@ -31,10 +31,10 @@ RSpec.shared_examples 'domain mailer pending update request for old registrant'
expect(rendered).to have_text('test new registrant english') expect(rendered).to have_text('test new registrant english')
end end
it 'has verification url' do it 'has confirm url' do
mention_count = 1 * lang_count mention_count = 1 * lang_count
render render
expect(rendered).to have_text('test verification url', count: mention_count) expect(rendered).to have_text('test confirm url', count: mention_count)
end end
domain_attributes = %i( domain_attributes = %i(

View file

@ -0,0 +1,13 @@
require 'rails_helper'
require_relative 'notice_shared'
RSpec.describe 'mailers/registrant_change_mailer/notice.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 'registrant change mailer notice'
end

View file

@ -0,0 +1,13 @@
require 'rails_helper'
require_relative 'notice_shared'
RSpec.describe 'mailers/registrant_change_mailer/notice.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 'registrant change mailer notice'
end

View file

@ -1,13 +1,16 @@
require 'rails_helper' require 'rails_helper'
RSpec.shared_examples 'domain mailer pending update notification for new registrant' do RSpec.shared_examples 'registrant change mailer notice' do
let(:domain) { instance_spy(DomainPresenter) } let(:domain) { instance_spy(DomainPresenter) }
let(:registrar) { instance_spy(RegistrarPresenter) } let(:registrar) { instance_spy(RegistrarPresenter) }
let(:registrant) { instance_spy(RegistrantPresenter) }
let(:lang_count) { 2 } let(:lang_count) { 2 }
before :example do before :example do
assign(:domain, domain) assign(:domain, domain)
assign(:registrar, registrar) assign(:registrar, registrar)
assign(:current_registrant, registrant)
assign(:new_registrant, registrant)
end end
it 'has registrar info in estonian' do it 'has registrar info in estonian' do
@ -20,10 +23,14 @@ RSpec.shared_examples 'domain mailer pending update notification for new registr
expect(rendered).to have_text('test registrar english') expect(rendered).to have_text('test registrar english')
end end
it 'has registrar name' do it 'has new registrant info in estonian' do
expect(registrar).to receive(:name).and_return('test registrar name')
render render
expect(rendered).to have_text('test registrar name') expect(rendered).to have_text('test new registrant estonian')
end
it 'has new registrant info in english' do
render
expect(rendered).to have_text('test new registrant english')
end end
domain_attributes = %i( domain_attributes = %i(

View file

@ -1,6 +0,0 @@
require 'rails_helper'
require_relative 'pending_update_notification_for_new_registrant_shared'
RSpec.describe 'mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb' do
include_examples 'domain mailer pending update notification for new registrant'
end

View file

@ -1,9 +0,0 @@
require 'rails_helper'
require_relative 'pending_update_notification_for_new_registrant_shared'
RSpec.describe 'mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb' do
include_examples 'domain mailer pending update notification for new registrant'
end

View file

@ -0,0 +1,11 @@
require 'rails_helper'
require_relative 'rejected_shared'
RSpec.describe 'mailers/registrant_change_mailer/rejected.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 'registrant change mailer rejected'
end

View file

@ -0,0 +1,11 @@
require 'rails_helper'
require_relative 'rejected_shared'
RSpec.describe 'mailers/registrant_change_mailer/rejected.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 'registrant change mailer rejected'
end

View file

@ -0,0 +1,48 @@
require 'rails_helper'
RSpec.shared_examples 'registrant change mailer rejected' do
let(:domain) { instance_spy(DomainPresenter) }
let(:registrar) { instance_spy(RegistrarPresenter) }
let(:registrant) { instance_spy(RegistrantPresenter) }
let(:lang_count) { 2 }
before :example do
assign(:domain, domain)
assign(:registrar, registrar)
assign(:registrant, registrant)
end
it 'has registrar info in estonian' do
render
expect(rendered).to have_text('test registrar estonian')
end
it 'has registrar info in english' do
render
expect(rendered).to have_text('test registrar english')
end
domain_attributes = %i(
name
)
domain_attributes.each do |attr_name|
it "has domain #{attr_name}" do
expect(domain).to receive(attr_name).exactly(lang_count).times.and_return("test domain #{attr_name}")
render
expect(rendered).to have_text("test domain #{attr_name}", count: lang_count)
end
end
registrant_attributes = %i(
name
)
registrant_attributes.each do |attr_name|
it "has registrant #{attr_name}" do
expect(registrant).to receive(attr_name).exactly(lang_count).times.and_return("test registrant #{attr_name}")
render
expect(rendered).to have_text("test registrant #{attr_name}", count: lang_count)
end
end
end