Add extended registrar's info to "pending_update_request_for_old_registrant" mailer

#180
This commit is contained in:
Artur Beljajev 2016-11-07 02:22:03 +02:00
parent 34c1e0d323
commit fc9104a232
11 changed files with 239 additions and 32 deletions

View file

@ -1,8 +1,14 @@
class DomainMailer < ApplicationMailer
include Que::Mailer
def pending_update_request_for_old_registrant(params)
compose_from(params)
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)

View file

@ -1,17 +1,11 @@
class RegistrantPresenter
delegate :name, :ident, :email, to: :registrant
def initialize(registrant:, view:)
@registrant = registrant
@view = view
end
def name
registrant.name
end
def ident
registrant.ident
end
private
attr_reader :registrant

View file

@ -1,13 +1,21 @@
Tere
<br><br>
Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @params[:registrar_name] %> poole.
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<p>
<%= @registrar.name %><br>
Email: <%= @registrar.email %><br>
Telefon: <%= @registrar.phone %><br>
Veebileht: <%= @registrar.url %>
</p>
<br><br>
Uue registreerija andmed:<br>
Nimi: <%= @params[:registrant_name] %><br>
Nimi: <%= @registrant.name %><br>
<% if @params[:registrant_priv] %>
Isikukood: <%= @params[:registrant_ident] %><br>
Isikukood: <%= @registrant.ident %><br>
<% else %>
Äriregistrikood: <%= @params[:registrant_ident] %><br>
Äriregistrikood: <%= @registrant.ident %><br>
<% end %>
Tänav: <%= @params[:registrant_street] %><br>
Linn: <%= @params[:registrant_city] %><br>
@ -17,7 +25,7 @@ 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 @params[:verification_url], @params[:verification_url] %>
<%= link_to @verification_url, @verification_url %>
<br><br>
Lugupidamisega<br>
Eesti Interneti Sihtasutus
@ -26,14 +34,22 @@ Eesti Interneti Sihtasutus
<br><br>
Hi,
<br><br>
Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %>
Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar:
<p>
<%= @registrar.name %><br>
Email: <%= @registrar.email %><br>
Phone: <%= @registrar.phone %><br>
Website: <%= @registrar.url %>
</p>
<br><br>
New registrant:<br>
Name: <%= @params[:registrant_name] %><br>
Name: <%= @registrant.name %><br>
<% if @params[:registrant_priv] %>
Personal code: <%= @params[:registrant_ident] %><br>
Personal code: <%= @registrant.ident %><br>
<% else %>
Business Registry code: <%= @params[:registrant_ident] %><br>
Business Registry code: <%= @registrant.ident %><br>
<% end %>
Street: <%= @params[:registrant_street] %><br>
City: <%= @params[:registrant_city] %><br>
@ -42,7 +58,7 @@ Country: <%= @params[:registrant_country] %>
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 @params[:verification_url], @params[:verification_url] %>
<%= link_to @verification_url, @verification_url %>
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -1,13 +1,18 @@
Tere
Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja <%= @params[:registrar_name] %> poole.
Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
<%= @registrar.name %>
Email: <%= @registrar.email %>
Telefon: <%= @registrar.phone %>
Veebileht: <%= @registrar.url %>
Uue registreerija andmed:
Nimi: <%= @params[:registrant_name] %>
Nimi: <%= @registrant.name %>
<% if @params[:registrant_priv] %>
Isikukood: <%= @params[:registrant_ident] %>
Isikukood: <%= @registrant.ident %>
<% else %>
Äriregistrikood: <%= @params[:registrant_ident] %>
Äriregistrikood: <%= @registrant.ident %>
<% end %>
Tänav: <%= @params[:registrant_street] %>
Linn: <%= @params[:registrant_city] %>
@ -15,7 +20,7 @@ Riik: <%= @params[:registrant_country] %>
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:
<%= @params[:verification_url] %>
<%= @verification_url %>
Lugupidamisega
Eesti Interneti Sihtasutus
@ -24,14 +29,19 @@ Eesti Interneti Sihtasutus
Hi,
Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %>
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:
<%= @registrar.name %>
Email: <%= @registrar.email %>
Phone: <%= @registrar.phone %>
Website: <%= @registrar.url %>
New registrant:
Name: <%= @params[:registrant_name] %>
Name: <%= @registrant.name %>
<% if @params[:registrant_priv] %>
Personal code: <%= @params[:registrant_ident] %>
Personal code: <%= @registrant.ident %>
<% else %>
Business Registry code: <%= @params[:registrant_ident] %>
Business Registry code: <%= @registrant.ident %>
<% end %>
Street: <%= @params[:registrant_street] %>
City: <%= @params[:registrant_city] %>
@ -39,7 +49,7 @@ Country: <%= @params[:registrant_country] %>
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:
<%= @params[:verification_url] %>
<%= @verification_url %>
Best Regards,
Estonian Internet Foundation

View file

@ -339,7 +339,6 @@ en:
contact_details: 'Contact details'
ident: 'Ident'
ident_type: 'Ident type'
address: 'Address'
country: 'Country'
city: 'City'
street: 'Street'
@ -797,7 +796,6 @@ en:
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'
object_status_prohibits_operation: 'Object status prohibits operation'
pending_update_request_for_old_registrant_subject: "Kinnitustaotlus domeeni %{name} registreerija vahetuseks / Application for approval for registrant change of %{name}"
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"

View file

@ -1,5 +1,7 @@
en:
domain_mailer:
pending_update_request_for_old_registrant:
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:

View file

@ -1,6 +1,49 @@
require 'rails_helper'
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') }

View file

@ -17,4 +17,11 @@ RSpec.describe RegistrantPresenter do
expect(presenter.ident).to eq('test ident')
end
end
describe '#email' do
it 'returns email' do
expect(registrant).to receive(:email).and_return('test email')
expect(presenter.email).to eq('test email')
end
end
end

View file

@ -0,0 +1,9 @@
require 'rails_helper'
RSpec.describe Registrant::DomainUpdateConfirmsController do
describe 'routing' do
it 'routes to #show' do
expect(get: '/registrant/domain_update_confirms/1').to route_to('registrant/domain_update_confirms#show', id: '1')
end
end
end

View file

@ -0,0 +1,61 @@
require 'rails_helper'
RSpec.describe 'mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb' 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)
assign(:verification_url, 'test url')
end
it 'has verification url' do
mention_count = 1 * lang_count
render
expect(rendered).to have_text('test url', count: mention_count)
end
registrar_attributes = %i(
name
email
phone
url
)
registrar_attributes.each do |attr_name|
it "has registrar #{attr_name}" do
expect(registrar).to receive(attr_name).exactly(lang_count).times.and_return("test registrar #{attr_name}")
render
expect(rendered).to have_text("test registrar #{attr_name}", count: lang_count)
end
end
domain_attributes = %i(
name
)
domain_attributes.each do |attr_name|
it "has :#{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
registrant_attributes = %i(
name
ident
)
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

View file

@ -0,0 +1,61 @@
require 'rails_helper'
RSpec.describe 'mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb' 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)
assign(:verification_url, 'test url')
end
it 'has verification url' do
mention_count = 1 * lang_count
render
expect(rendered).to have_text('test url', count: mention_count)
end
registrar_attributes = %i(
name
email
phone
url
)
registrar_attributes.each do |attr_name|
it "has registrar #{attr_name}" do
expect(registrar).to receive(attr_name).exactly(lang_count).times.and_return("test registrar #{attr_name}")
render
expect(rendered).to have_text("test registrar #{attr_name}", count: lang_count)
end
end
domain_attributes = %i(
name
)
domain_attributes.each do |attr_name|
it "has :#{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
registrant_attributes = %i(
name
ident
)
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