Improve RegistrantChangeMailer

- Do not show registrant address unless "address_processing" is enabled
- Add missing registrant state and zip attributes

#480
This commit is contained in:
Artur Beljajev 2017-05-18 15:59:06 +03:00
parent 2c648ddc84
commit bfc0c0b74f
14 changed files with 164 additions and 43 deletions

View file

@ -2,5 +2,5 @@ require 'rails_helper'
require_relative 'registrant_shared'
RSpec.describe 'mailers/shared/registrant/_registrant.en.html.erb' do
include_examples 'domain mailer registrant info'
include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.en.html.erb'
end

View file

@ -2,5 +2,5 @@ require 'rails_helper'
require_relative 'registrant_shared'
RSpec.describe 'mailers/shared/registrant/_registrant.en.text.erb' do
include_examples 'domain mailer registrant info'
include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.en.text.erb'
end

View file

@ -2,5 +2,5 @@ require 'rails_helper'
require_relative 'registrant_shared'
RSpec.describe 'mailers/shared/registrant/_registrant.et.html.erb' do
include_examples 'domain mailer registrant info'
include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.et.html.erb'
end

View file

@ -2,5 +2,5 @@ require 'rails_helper'
require_relative 'registrant_shared'
RSpec.describe 'mailers/shared/registrant/_registrant.et.text.erb' do
include_examples 'domain mailer registrant info'
include_examples 'domain mailer registrant info', 'mailers/shared/registrant/_registrant.et.text.erb'
end

View file

@ -1,25 +1,65 @@
require 'rails_helper'
RSpec.shared_examples 'domain mailer registrant info' do
RSpec.shared_examples 'domain mailer registrant info' do |template_path|
let(:template_path) { template_path }
let(:registrant) { instance_spy(RegistrantPresenter) }
before :example do
allow(view).to receive(:registrant).and_return(registrant)
allow(view).to receive(:address_processing)
end
attributes = %i(
name
ident
street
city
country
)
it 'has name' do
allow(registrant).to receive(:name).and_return('test name')
render template: template_path
expect(rendered).to have_text('test name')
end
attributes.each do |attr_name|
it "has #{attr_name}" do
expect(registrant).to receive(attr_name).and_return("test #{attr_name}")
render
expect(rendered).to have_text("test #{attr_name}")
it 'has ident' do
allow(registrant).to receive(:ident).and_return('test ident')
render template: template_path
expect(rendered).to have_text('test ident')
end
address_attributes = %i[street city state zip country]
context 'when address processing is enabled' do
before :example do
allow(view).to receive(:address_processing).and_return(true)
end
address_attributes.each do |attr_name|
it "has #{attr_name}" do
allow(registrant).to receive(attr_name).and_return("test #{attr_name}")
render template: template_path
expect(rendered).to have_text("test #{attr_name}")
end
end
it 'has no ident country' do
allow(registrant).to receive(:ident_country).and_return('test ident country')
render template: template_path
expect(rendered).to_not have_text('test ident country')
end
end
context 'when address processing is disabled' do
before :example do
allow(view).to receive(:address_processing).and_return(false)
end
address_attributes.each do |attr_name|
it "has no #{attr_name}" do
allow(registrant).to receive(attr_name).and_return("test #{attr_name}")
render template: template_path
expect(rendered).to_not have_text("test #{attr_name}")
end
end
it 'has ident country' do
allow(registrant).to receive(:ident_country).and_return('test ident country')
render template: template_path
expect(rendered).to have_text('test ident country')
end
end
end