mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Merge pull request #1149 from internetee/improve-registrant-change-mailer
Improve registrant change mailer
This commit is contained in:
commit
c192cc0538
33 changed files with 104 additions and 446 deletions
|
@ -4,10 +4,10 @@ class RegistrantChangeConfirmEmailJob < Que::Job
|
|||
new_registrant = Registrant.find(new_registrant_id)
|
||||
|
||||
log(domain)
|
||||
RegistrantChangeMailer.confirm(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
current_registrant: domain.registrant,
|
||||
new_registrant: new_registrant).deliver_now
|
||||
RegistrantChangeMailer.confirmation_request(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
current_registrant: domain.registrant,
|
||||
new_registrant: new_registrant).deliver_now
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -3,10 +3,10 @@ class RegistrantChangeNoticeEmailJob < Que::Job
|
|||
domain = Domain.find(domain_id)
|
||||
new_registrant = Registrant.find(new_registrant_id)
|
||||
log(domain, new_registrant)
|
||||
RegistrantChangeMailer.notice(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
current_registrant: domain.registrant,
|
||||
new_registrant: new_registrant).deliver_now
|
||||
RegistrantChangeMailer.notification(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
current_registrant: domain.registrant,
|
||||
new_registrant: new_registrant).deliver_now
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
class RegistrantChangeMailer < ApplicationMailer
|
||||
helper_method :address_processing
|
||||
|
||||
def confirm(domain:, registrar:, current_registrant:, new_registrant:)
|
||||
def confirmation_request(domain:, registrar:, current_registrant:, new_registrant:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
|
||||
@new_registrant = RegistrantPresenter.new(registrant: new_registrant, view: view_context)
|
||||
@confirm_url = confirm_url(domain)
|
||||
@confirmation_url = confirmation_url(domain)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: current_registrant.email, subject: subject)
|
||||
end
|
||||
|
||||
def notice(domain:, registrar:, current_registrant:, new_registrant:)
|
||||
def notification(domain:, registrar:, current_registrant:, new_registrant:)
|
||||
@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)
|
||||
|
@ -21,7 +21,7 @@ class RegistrantChangeMailer < ApplicationMailer
|
|||
mail(to: new_registrant.email, subject: subject)
|
||||
end
|
||||
|
||||
def confirmed(domain:, old_registrant:)
|
||||
def accepted(domain:, old_registrant:)
|
||||
@domain = domain
|
||||
recipients = [domain.registrant.email, old_registrant.email]
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
|
@ -49,7 +49,7 @@ class RegistrantChangeMailer < ApplicationMailer
|
|||
|
||||
private
|
||||
|
||||
def confirm_url(domain)
|
||||
def confirmation_url(domain)
|
||||
registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class RegistrantChange
|
|||
private
|
||||
|
||||
def notify_registrant
|
||||
RegistrantChangeMailer.confirmed(domain: domain, old_registrant: old_registrant).deliver_now
|
||||
RegistrantChangeMailer.accepted(domain: domain, old_registrant: old_registrant).deliver_now
|
||||
end
|
||||
|
||||
attr_reader :domain
|
||||
|
|
|
@ -8,10 +8,7 @@ Domeeni <%= domain.name %> registreerija vahetuse taotlus on kinnitatud ning and
|
|||
<br><br>
|
||||
Uue registreerija andmed:<br>
|
||||
<%= render 'mailers/shared/registrant/registrant.et.html', registrant: new_registrant %>
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
Eesti Interneti Sihtasutus
|
||||
<br><br>
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
<hr>
|
||||
<br><br>
|
||||
Hi,
|
||||
|
@ -20,6 +17,4 @@ Process for changing registrant of the domain <%= domain.name %> has been approv
|
|||
<br><br>
|
||||
New registrant:<br>
|
||||
<%= render 'mailers/shared/registrant/registrant.en.html', registrant: new_registrant %>
|
||||
<br><br>
|
||||
Best Regards,<br>
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
|
@ -9,9 +9,7 @@ Domeeni <%= domain.name %> registreerija vahetuse taotlus on kinnitatud ning and
|
|||
Uue registreerija andmed:
|
||||
<%= render 'mailers/shared/registrant/registrant.et.text', registrant: new_registrant %>
|
||||
|
||||
Lugupidamisega
|
||||
Eesti Interneti Sihtasutus
|
||||
|
||||
<%= render 'mailers/shared/signatures/signature.et.text' %>
|
||||
--------------------------------------
|
||||
|
||||
Hi,
|
||||
|
@ -21,5 +19,4 @@ Process for changing registrant of the domain <%= domain.name %> has been approv
|
|||
New registrant:
|
||||
<%= render 'mailers/shared/registrant/registrant.en.text', registrant: new_registrant %>
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.text' %>
|
|
@ -12,11 +12,8 @@ Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatak
|
|||
<br><br>
|
||||
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:<br>
|
||||
|
||||
<%= link_to @confirm_url, @confirm_url %>
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
Eesti Interneti Sihtasutus
|
||||
<br><br>
|
||||
<%= link_to @confirmation_url, @confirmation_url %>
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
<hr>
|
||||
<br><br>
|
||||
Hi,
|
||||
|
@ -32,7 +29,5 @@ New registrant:<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.
|
||||
<br><br>
|
||||
To confirm the update please visit this website, once again review the data and press approve:<br>
|
||||
<%= link_to @confirm_url, @confirm_url %>
|
||||
<br><br>
|
||||
Best Regards,<br>
|
||||
Estonian Internet Foundation
|
||||
<%= link_to @confirmation_url, @confirmation_url %>
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
|
@ -9,10 +9,9 @@ Uue registreerija andmed:
|
|||
|
||||
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:
|
||||
<%= @confirm_url %>
|
||||
<%= @confirmation_url %>
|
||||
|
||||
Lugupidamisega
|
||||
Eesti Interneti Sihtasutus
|
||||
<%= render 'mailers/shared/signatures/signature.et.text' %>
|
||||
|
||||
--------------------------------------
|
||||
|
||||
|
@ -27,7 +26,6 @@ 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.
|
||||
To confirm the update please visit this website, once again review the data and press approve:
|
||||
<%= @confirm_url %>
|
||||
<%= @confirmation_url %>
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.text' %>
|
|
@ -5,11 +5,7 @@ Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> ei kinnitanud
|
|||
Küsimuste korral palun võtke ühendust oma registripidajaga:
|
||||
|
||||
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
Eesti Interneti Sihtasutus
|
||||
<br><br>
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
<hr>
|
||||
<br><br>
|
||||
Hi,
|
||||
|
@ -19,7 +15,4 @@ Domain registrant change request has been expired for the domain <%= @domain.nam
|
|||
Please contact to your registrar if you have any questions:
|
||||
|
||||
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Best Regards,<br>
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
|
@ -5,9 +5,7 @@ Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> ei kinnitanud
|
|||
Küsimuste korral palun võtke ühendust oma registripidajaga:
|
||||
|
||||
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
|
||||
|
||||
Lugupidamisega
|
||||
Eesti Interneti Sihtasutus
|
||||
<%= render 'mailers/shared/signatures/signature.et.text' %>
|
||||
|
||||
--------------------------------------
|
||||
|
||||
|
@ -19,5 +17,4 @@ Please contact to your registrar if you have any questions:
|
|||
|
||||
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.text' %>
|
|
@ -14,9 +14,7 @@ Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule
|
|||
<br><br>
|
||||
Juhul kui <%= @current_registrant.name %> lükkab omanikuvahetuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
Eesti Interneti Sihtasutus
|
||||
<br><br>
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
<hr>
|
||||
<br><br>
|
||||
Hi,
|
||||
|
@ -34,6 +32,4 @@ New registrant:<br>
|
|||
The registrant change procedure will be completed only after the current registrant <%= @current_registrant.name %> has approved it.
|
||||
<br><br>
|
||||
Change request will be cancelled in case <%= @current_registrant.name %> rejects or does not approve it in <%= Setting.expire_pending_confirmation %> hours.
|
||||
<br><br>
|
||||
Best Regards,<br>
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
|
@ -13,8 +13,7 @@ Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiakse lõpule
|
|||
|
||||
Juhul kui <%= @current_registrant.name %> lükkab omanikuvahetuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.
|
||||
|
||||
Lugupidamisega
|
||||
Eesti Interneti Sihtasutus
|
||||
<%= render 'mailers/shared/signatures/signature.et.text' %>
|
||||
|
||||
--------------------------------------
|
||||
|
||||
|
@ -33,5 +32,4 @@ The registrant change procedure will be completed only after the current registr
|
|||
|
||||
Change request will be cancelled in case <%= @current_registrant.name %> rejects or does not approve it in <%= Setting.expire_pending_confirmation %> hours.
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.text' %>
|
|
@ -5,11 +5,7 @@ Domeeni <%= @domain.name %> registreerija <%= @registrant.name %> on domeeni reg
|
|||
Küsimuste korral võtke palun ühendust oma registripidajaga:
|
||||
|
||||
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
Eesti Interneti Sihtasutus
|
||||
<br><br>
|
||||
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||
<hr>
|
||||
<br><br>
|
||||
Hi,
|
||||
|
@ -19,7 +15,4 @@ Registrant change for the domain <%= @domain.name %> was rejected by the registr
|
|||
Please contact your registrar if you have any questions:
|
||||
|
||||
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Best Regards,<br>
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
|
@ -6,8 +6,7 @@ Küsimuste korral võtke palun ühendust oma registripidajaga:
|
|||
|
||||
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
|
||||
|
||||
Lugupidamisega
|
||||
Eesti Interneti Sihtasutus
|
||||
<%= render 'mailers/shared/signatures/signature.et.text' %>
|
||||
|
||||
--------------------------------------
|
||||
|
||||
|
@ -19,5 +18,4 @@ Please contact your registrar if you have any questions:
|
|||
|
||||
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
||||
<%= render 'mailers/shared/signatures/signature.en.text' %>
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
en:
|
||||
registrant_change_mailer:
|
||||
confirm:
|
||||
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
|
||||
confirmed:
|
||||
confirmation_request:
|
||||
subject: >-
|
||||
Kinnitustaotlus domeeni %{domain_name} registreerija vahetuseks
|
||||
/ Application for approval for registrant change of %{domain_name}
|
||||
notification:
|
||||
subject: >-
|
||||
Domeeni %{domain_name} registreerija vahetus protseduur on algatatud
|
||||
/ %{domain_name} registrant change
|
||||
accepted:
|
||||
subject: >-
|
||||
Domeeni %{domain_name} registreerija vahetus teostatud
|
||||
/ Registrant change of %{domain_name} has been finished
|
||||
rejected:
|
||||
subject: >-
|
||||
Domeeni %{domain_name} registreerija vahetuse taotlus tagasi lükatud
|
||||
/ %{domain_name} registrant change declined
|
||||
expired:
|
||||
subject: Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud / %{domain_name} registrant change cancelled
|
||||
subject: >-
|
||||
Domeeni %{domain_name} registreerija vahetuse taotlus on tühistatud
|
||||
/ %{domain_name} registrant change cancelled
|
|
@ -7,7 +7,7 @@ RSpec.describe RegistrantChange do
|
|||
let(:message) { instance_spy(ActionMailer::MessageDelivery) }
|
||||
|
||||
before :example do
|
||||
allow(RegistrantChangeMailer).to receive(:confirmed)
|
||||
allow(RegistrantChangeMailer).to receive(:accepted)
|
||||
.with(domain: domain, old_registrant: old_registrant)
|
||||
.and_return(message)
|
||||
described_class.new(domain: domain, old_registrant: old_registrant).confirm
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'confirm_shared'
|
||||
|
||||
RSpec.describe 'mailers/domain_delete_mailer/confirm.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 'domain delete mailer confirm'
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'confirm_shared'
|
||||
|
||||
RSpec.describe 'mailers/domain_delete_mailer/confirm.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 'domain delete mailer confirm'
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'domain delete mailer confirm' do
|
||||
let(:domain) { instance_spy(DomainPresenter) }
|
||||
let(:lang_count) { 2 }
|
||||
|
||||
before :example do
|
||||
assign(:domain, domain)
|
||||
assign(:registrar, nil)
|
||||
assign(:confirm_url, 'test confirm url')
|
||||
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
|
||||
|
||||
it 'has domain name' do
|
||||
mention_count = 1 * lang_count
|
||||
expect(domain).to receive(:name).exactly(mention_count).times.and_return('test domain name')
|
||||
render
|
||||
expect(rendered).to have_text('test domain name', count: mention_count)
|
||||
end
|
||||
|
||||
it 'has confirm url' do
|
||||
mention_count = 1 * lang_count
|
||||
render
|
||||
expect(rendered).to have_text('test confirm url', count: mention_count)
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'confirm_shared'
|
||||
|
||||
RSpec.describe 'mailers/registrant_change_mailer/confirm.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 confirm'
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'confirm_shared'
|
||||
|
||||
RSpec.describe 'mailers/registrant_change_mailer/confirm.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 confirm'
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'registrant change mailer confirm' do
|
||||
let(:domain) { instance_spy(DomainPresenter) }
|
||||
let(:lang_count) { 2 }
|
||||
|
||||
before :example do
|
||||
assign(:domain, domain)
|
||||
assign(:registrar, nil)
|
||||
assign(:new_registrant, nil)
|
||||
assign(:confirm_url, 'test confirm url')
|
||||
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
|
||||
|
||||
it 'has new registrant info in estonian' do
|
||||
render
|
||||
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
|
||||
|
||||
it 'has confirm url' do
|
||||
mention_count = 1 * lang_count
|
||||
render
|
||||
expect(rendered).to have_text('test confirm url', count: mention_count)
|
||||
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(attr_name.to_s)
|
||||
render
|
||||
expect(rendered).to have_text(attr_name.to_s, count: lang_count)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'expired_shared'
|
||||
|
||||
RSpec.describe 'mailers/registrant_change_mailer/expired.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 expired'
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
require 'rails_helper'
|
||||
require_relative 'expired_shared'
|
||||
|
||||
RSpec.describe 'mailers/registrant_change_mailer/expired.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 expired'
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'registrant change mailer expired' 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
|
||||
mention_count = 3
|
||||
expect(domain).to receive(attr_name).exactly(mention_count).times.and_return("test domain #{attr_name}")
|
||||
render
|
||||
expect(rendered).to have_text("test domain #{attr_name}", count: mention_count)
|
||||
end
|
||||
end
|
||||
|
||||
registrant_attributes = %i(
|
||||
name
|
||||
)
|
||||
|
||||
registrant_attributes.each do |attr_name|
|
||||
it "has registrant #{attr_name}" do
|
||||
mention_count = 1
|
||||
expect(registrant).to receive(attr_name).exactly(mention_count).times.and_return("test registrant #{attr_name}")
|
||||
render
|
||||
expect(rendered).to have_text("test registrant #{attr_name}", count: mention_count)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
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
|
|
@ -1,13 +0,0 @@
|
|||
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
|
|
@ -1,47 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.shared_examples 'registrant change mailer notice' 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(:current_registrant, registrant)
|
||||
assign(:new_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
|
||||
|
||||
it 'has new registrant info in estonian' do
|
||||
render
|
||||
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
|
||||
|
||||
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
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
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
|
|
@ -1,11 +0,0 @@
|
|||
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
|
|
@ -1,48 +0,0 @@
|
|||
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
|
38
test/mailers/previews/registrant_change_mailer_preview.rb
Normal file
38
test/mailers/previews/registrant_change_mailer_preview.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue