Show registrant phone in ContactMailer

#480
This commit is contained in:
Artur Beljajev 2017-05-22 12:42:10 +03:00
parent 490ebf969c
commit adcebd084a
9 changed files with 48 additions and 13 deletions

View file

@ -1,5 +1,11 @@
class RegistrantPresenter
delegate :name, :ident, :email, :priv?, :id_code, :reg_no,
delegate :name,
:ident,
:phone,
:email,
:priv?,
:id_code,
:reg_no,
:street, :city, :state, :zip, :country,
:ident_country,
to: :registrant

View file

@ -17,7 +17,7 @@ Muudatusega seotud domeenid:<br>
<% end %>
<br>
Kontaktandmed:<br>
<%= render 'mailers/shared/registrant/registrant.et.html', registrant: contact %>
<%= render 'mailers/shared/registrant/registrant.et.html', registrant: contact, with_phone: true %>
<br><br>
Lugupidamisega<br>
Eesti Interneti Sihtasutus
@ -40,7 +40,7 @@ Domains affected by this update:<br>
<% end %>
<br>
Contact information:<br>
<%= render 'mailers/shared/registrant/registrant.en.html', registrant: contact %>
<%= render 'mailers/shared/registrant/registrant.en.html', registrant: contact, with_phone: true %>
<br><br>
Best Regards,<br>
Estonian Internet Foundation

View file

@ -17,7 +17,7 @@ Muudatusega seotud domeenid:
<% end %>
Kontaktandmed:
<%= render 'mailers/shared/registrant/registrant.et.text', registrant: contact %>
<%= render 'mailers/shared/registrant/registrant.et.text', registrant: contact, with_phone: true %>
Lugupidamisega
Eesti Interneti Sihtasutus
@ -40,7 +40,7 @@ Domains affected by this update:
<% end %>
Contact information:
<%= render 'mailers/shared/registrant/registrant.en.text', registrant: contact %>
<%= render 'mailers/shared/registrant/registrant.en.text', registrant: contact, with_phone: true %>
Best Regards,
Estonian Internet Foundation

View file

@ -4,7 +4,10 @@ Name: <%= registrant.name %><br>
<% else %>
Business Registry code: <%= registrant.ident %><br>
<% end %>
<% if address_processing %>
<% if local_assigns[:with_phone] -%>
Phone: <%= registrant.phone %><br>
<% end -%>
<% if address_processing -%>
Street: <%= registrant.street %><br>
City: <%= registrant.city %><br>
State: <%= registrant.state %><br>
@ -12,4 +15,4 @@ Name: <%= registrant.name %><br>
Country: <%= registrant.country %>
<% else %>
Country: <%= registrant.ident_country %>
<% end %>
<% end -%>

View file

@ -4,7 +4,10 @@ Name: <%= registrant.name %>
<% else %>
Business Registry code: <%= registrant.ident %>
<% end %>
<% if address_processing %>
<% if local_assigns[:with_phone] -%>
Phone: <%= registrant.phone %>
<% end -%>
<% if address_processing -%>
Street: <%= registrant.street %>
City: <%= registrant.city %>
State: <%= registrant.state %>
@ -12,4 +15,4 @@ Name: <%= registrant.name %>
Country: <%= registrant.country %>
<% else %>
Country: <%= registrant.ident_country %>
<% end %>
<% end -%>

View file

@ -4,7 +4,10 @@ Nimi: <%= registrant.name %><br>
<% else %>
Äriregistrikood: <%= registrant.ident %><br>
<% end %>
<% if address_processing %>
<% if local_assigns[:with_phone] -%>
Telefon: <%= registrant.phone %><br>
<% end -%>
<% if address_processing -%>
Tänav: <%= registrant.street %><br>
Linn: <%= registrant.city %><br>
Maakond: <%= registrant.state %><br>
@ -12,4 +15,4 @@ Nimi: <%= registrant.name %><br>
Riik: <%= registrant.country(locale: :et) %>
<% else %>
Riik: <%= registrant.ident_country(locale: :et) %>
<% end %>
<% end -%>

View file

@ -4,7 +4,10 @@ Nimi: <%= registrant.name %>
<% else %>
Äriregistrikood: <%= registrant.ident %>
<% end %>
<% if address_processing %>
<% if local_assigns[:with_phone] -%>
Telefon: <%= registrant.phone %>
<% end -%>
<% if address_processing -%>
Tänav: <%= registrant.street %>
Linn: <%= registrant.city %>
Maakond: <%= registrant.state %>
@ -12,4 +15,4 @@ Nimi: <%= registrant.name %>
Riik: <%= registrant.country(locale: :et) %>
<% else %>
Riik: <%= registrant.ident_country(locale: :et) %>
<% end %>
<% end -%>

View file

@ -43,6 +43,7 @@ RSpec.describe RegistrantPresenter do
registrant_delegatable_attributes = %i(
name
ident
phone
email
priv?
street

View file

@ -21,6 +21,22 @@ RSpec.shared_examples 'domain mailer registrant info' do |template_path|
expect(rendered).to have_text('test ident')
end
context 'when :with_phone is true' do
it 'has phone' do
allow(registrant).to receive(:phone).and_return('test phone')
render template: template_path, locals: { with_phone: true }
expect(rendered).to have_text('test phone')
end
end
context 'when :with_phone is false' do
it 'has no phone' do
allow(registrant).to receive(:phone).and_return('test phone')
render template: template_path, locals: { with_phone: false }
expect(rendered).to_not have_text('test phone')
end
end
address_attributes = %i[street city state zip country]
context 'when address processing is enabled' do