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,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