mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
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:
parent
2c648ddc84
commit
bfc0c0b74f
14 changed files with 164 additions and 43 deletions
|
@ -4,29 +4,61 @@ RSpec.describe RegistrantPresenter do
|
|||
let(:registrant) { instance_double(Registrant) }
|
||||
let(:presenter) { described_class.new(registrant: registrant, view: view) }
|
||||
|
||||
registrant_delegate_attributes = %i(
|
||||
describe '#country' do
|
||||
let(:country) { instance_double(Country) }
|
||||
|
||||
before :example do
|
||||
allow(registrant).to receive(:country).and_return(country)
|
||||
end
|
||||
|
||||
it 'returns country name in current locale by default' do
|
||||
expect(country).to receive(:translation).with(I18n.locale).and_return('test country')
|
||||
expect(presenter.country).to eq('test country')
|
||||
end
|
||||
|
||||
it 'returns country name in given locale' do
|
||||
expect(country).to receive(:translation).with(:de).and_return('test country')
|
||||
expect(presenter.country(locale: :de)).to eq('test country')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#ident_country' do
|
||||
let(:ident_country) { instance_double(Country) }
|
||||
|
||||
before :example do
|
||||
allow(registrant).to receive(:ident_country).and_return(ident_country)
|
||||
end
|
||||
|
||||
it 'returns country name in current locale by default' do
|
||||
expect(ident_country).to receive(:translation).with(I18n.locale).and_return('test country')
|
||||
expect(presenter.ident_country).to eq('test country')
|
||||
end
|
||||
|
||||
it 'returns country name in given locale' do
|
||||
expect(ident_country).to receive(:translation).with(:de).and_return('test country')
|
||||
expect(presenter.ident_country(locale: :de)).to eq('test country')
|
||||
end
|
||||
end
|
||||
|
||||
registrant_delegatable_attributes = %i(
|
||||
name
|
||||
ident
|
||||
email
|
||||
priv?
|
||||
street
|
||||
city
|
||||
state
|
||||
zip
|
||||
id_code
|
||||
reg_no
|
||||
)
|
||||
|
||||
registrant_delegate_attributes.each do |attribute_name|
|
||||
describe "##{attribute_name}" do
|
||||
it 'delegetes to registrant' do
|
||||
expect(registrant).to receive(attribute_name).and_return('test')
|
||||
expect(presenter.send(attribute_name)).to eq('test')
|
||||
registrant_delegatable_attributes.each do |attr_name|
|
||||
describe "##{attr_name}" do
|
||||
it 'delegates to registrant' do
|
||||
expect(registrant).to receive(attr_name).and_return('test')
|
||||
expect(presenter.send(attr_name)).to eq('test')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#country' do
|
||||
it 'returns country name' do
|
||||
expect(presenter.country).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue