From 878748836fef8db9d414c7c5d768d17297f6bc84 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 2 Jan 2017 13:02:50 +0200 Subject: [PATCH 1/5] Hide address form fields when adding/editing contact in registrar area #290 --- app/views/registrar/contacts/_form.haml | 9 ++-- .../contacts/form_partials/_address.haml | 21 ++++---- .../registrar/contacts/_form.haml_spec.rb | 38 ++++++++++++++ .../form_partials/_address.haml_spec.rb | 51 ------------------- 4 files changed, 54 insertions(+), 65 deletions(-) create mode 100644 spec/views/registrar/contacts/_form.haml_spec.rb delete mode 100644 spec/views/registrar/contacts/form_partials/_address.haml_spec.rb diff --git a/app/views/registrar/contacts/_form.haml b/app/views/registrar/contacts/_form.haml index 7b3c2df32..f826d0677 100644 --- a/app/views/registrar/contacts/_form.haml +++ b/app/views/registrar/contacts/_form.haml @@ -4,9 +4,12 @@ .row .col-md-8 = render 'registrar/contacts/form_partials/general', f: f -.row - .col-md-8 - = render 'registrar/contacts/form_partials/address', f: f + +- if address_processing? + .row + .col-md-8 + = render 'registrar/contacts/form_partials/address', f: f + - if !@contact.persisted? .row .col-md-8 diff --git a/app/views/registrar/contacts/form_partials/_address.haml b/app/views/registrar/contacts/form_partials/_address.haml index bc91da92c..1d9ae5869 100644 --- a/app/views/registrar/contacts/form_partials/_address.haml +++ b/app/views/registrar/contacts/form_partials/_address.haml @@ -4,21 +4,21 @@ .panel-body .form-group .col-md-3.control-label - = f.label :street, t(:street) + = f.label :street, t(:street) + '*' .col-md-7 - = f.text_field :street, class: 'form-control', required: address_processing? + = f.text_field :street, class: 'form-control', required: true .form-group .col-md-3.control-label - = f.label :city, t(:city) + = f.label :city, t(:city) + '*' .col-md-7 - = f.text_field :city, class: 'form-control', required: address_processing? + = f.text_field :city, class: 'form-control', required: true .form-group .col-md-3.control-label - = f.label :zip, t(:zip) + = f.label :zip, t(:zip) + '*' .col-md-7 - = f.text_field :zip, class: 'form-control', required: address_processing? + = f.text_field :zip, class: 'form-control', required: true .form-group .col-md-3.control-label @@ -28,10 +28,9 @@ .form-group .col-md-3.control-label - = f.label :country_code, t(:country) + = f.label :country_code, t(:country) + '*' .col-md-7 - country_selected = f.object.persisted? ? f.object.country_code : 'EE' - = f.select(:country_code, - SortedCountry.all_options(country_selected), - { include_blank: true }, - required: address_processing?) + = f.select(:country_code, SortedCountry.all_options(country_selected), + { include_blank: true }, required: true) + diff --git a/spec/views/registrar/contacts/_form.haml_spec.rb b/spec/views/registrar/contacts/_form.haml_spec.rb new file mode 100644 index 000000000..307c495e8 --- /dev/null +++ b/spec/views/registrar/contacts/_form.haml_spec.rb @@ -0,0 +1,38 @@ +require 'rails_helper' + +RSpec.describe 'registrar/contacts/_form' do + let(:contact) { instance_spy(Depp::Contact) } + + before :example do + allow(view).to receive(:f).and_return(ActionView::Helpers::FormBuilder.new(:contact, contact, view, {})) + assign(:contact, contact) + + stub_template 'registrar/shared/_error_messages' => '' + stub_template 'registrar/contacts/form_partials/_general' => '' + stub_template 'registrar/contacts/form_partials/_address' => 'address info' + stub_template 'registrar/contacts/form_partials/_code' => '' + stub_template 'registrar/contacts/form_partials/_legal_document' => '' + end + + context 'when address processing is enabled' do + before do + allow(view).to receive(:address_processing?).and_return(true) + end + + it 'has address' do + render + expect(rendered).to have_text('address info') + end + end + + context 'when address processing is disabled' do + before do + allow(view).to receive(:address_processing?).and_return(false) + end + + it 'has no address' do + render + expect(rendered).to_not have_text('address info') + end + end +end diff --git a/spec/views/registrar/contacts/form_partials/_address.haml_spec.rb b/spec/views/registrar/contacts/form_partials/_address.haml_spec.rb deleted file mode 100644 index 990d44b67..000000000 --- a/spec/views/registrar/contacts/form_partials/_address.haml_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'rails_helper' - -module RequiredAddressFieldsHelper - def define_field_examples(attr_name) - describe "#{attr_name} field" do - let(:field) { page.find("[name='depp_contact[#{attr_name}]']") } - - context 'when address processing is enabled' do - before do - allow(view).to receive(:address_processing?).and_return(true) - end - - it 'is required' do - render - expect(field[:required]).to eq('required') - end - end - - context 'when address processing is disabled' do - before do - allow(view).to receive(:address_processing?).and_return(false) - end - - it 'is optional' do - render - expect(field[:required]).to be_nil - end - end - end - end -end - -RSpec.describe 'registrar/contacts/form_partials/_address' do - extend RequiredAddressFieldsHelper - let(:contact) { instance_spy(Depp::Contact) } - - before do - allow(view).to receive(:f).and_return(ActionView::Helpers::FormBuilder.new(:depp_contact, contact, view, {})) - end - - required_address_attributes = %i( - street - city - zip - country_code - ) - - required_address_attributes.each do |attr_name| - define_field_examples(attr_name) - end -end From eb95299c8262bcd66cd7db2b0a40a95fe6a2d30b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 5 Jan 2017 19:18:19 +0200 Subject: [PATCH 2/5] Fix domain mailer email sending for registrants without address #330 --- ...d_notification_for_new_registrant.html.erb | 4 +- ...d_notification_for_new_registrant.text.erb | 4 +- ...d_notification_for_old_registrant.html.erb | 4 +- ...d_notification_for_old_registrant.text.erb | 4 +- spec/factories/contact.rb | 14 +++++ spec/factories/registrant.rb | 2 + spec/mailers/domain_mailer_spec.rb | 54 +++++++++++++++++++ 7 files changed, 78 insertions(+), 8 deletions(-) diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb index dc493969c..07d55e11e 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb @@ -12,7 +12,7 @@ Nimi: <%= @new_registrant.name %>
Epost: <%= @new_registrant.email %>
Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
-Riik: <%= @new_registrant.country.name %> +Riik: <%= @new_registrant.country.try(:name) %>

Lugupidamisega
Eesti Interneti Sihtasutus @@ -33,7 +33,7 @@ Name: <%= @new_registrant.name %>
E-mail: <%= @new_registrant.email %>
Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
-Country: <%= @new_registrant.country.name %> +Country: <%= @new_registrant.country.try(:name) %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb index 0fd6a609e..bd53aa535 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb @@ -13,7 +13,7 @@ Nimi: <%= @new_registrant.name %> Epost: <%= @new_registrant.email %> Tänav: <%= @new_registrant.street %> Linn: <%= @new_registrant.city %> -Riik: <%= @new_registrant.country.name %> +Riik: <%= @new_registrant.country.try(:name) %> Lugupidamisega Eesti Interneti Sihtasutus @@ -35,7 +35,7 @@ Name: <%= @new_registrant.name %> E-mail: <%= @new_registrant.email %> Street: <%= @new_registrant.street %> City: <%= @new_registrant.city %> -Country: <%= @new_registrant.country.name %> +Country: <%= @new_registrant.country.try(:name) %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index 428994e36..3f0930d57 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -12,7 +12,7 @@ Isikukood: <%= @new_registrant.ident %>
Epost: <%= @new_registrant.email %>
Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
-Riik: <%= @new_registrant.country.name %> +Riik: <%= @new_registrant.country.try(:name) %>

Lugupidamisega
Eesti Interneti Sihtasutus @@ -33,7 +33,7 @@ Business Registry code: <%= @new_registrant.ident %>
E-mail: <%= @new_registrant.email %>
Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
-Country: <%= @new_registrant.country.name %> +Country: <%= @new_registrant.country.try(:name) %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index a99eca6ba..5bf78a409 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -13,7 +13,7 @@ Isikukood: <%= @new_registrant.ident %> Epost: <%= @new_registrant.email %> Tänav: <%= @new_registrant.street %> Linn: <%= @new_registrant.city %> -Riik: <%= @new_registrant.country.name %> +Riik: <%= @new_registrant.country.try(:name) %> Lugupidamisega Eesti Interneti Sihtasutus @@ -35,7 +35,7 @@ Business Registry code: <%= @new_registrant.ident %> E-mail: <%= @new_registrant.email %> Street: <%= @new_registrant.street %> City: <%= @new_registrant.city %> -Country: <%= @new_registrant.country.name %> +Country: <%= @new_registrant.country.try(:name) %> Best Regards, Estonian Internet Foundation diff --git a/spec/factories/contact.rb b/spec/factories/contact.rb index 7122babd5..e47b67012 100644 --- a/spec/factories/contact.rb +++ b/spec/factories/contact.rb @@ -21,5 +21,19 @@ FactoryGirl.define do ident_type 'org' ident '12345678' # valid reg no for .ee end + + factory :contact_with_address do + street 'test' + city 'test' + zip 12345 + country_code 'EE' + end + + factory :contact_without_address do + street nil + city nil + zip nil + country_code nil + end end end diff --git a/spec/factories/registrant.rb b/spec/factories/registrant.rb index f25942829..d84d1688e 100644 --- a/spec/factories/registrant.rb +++ b/spec/factories/registrant.rb @@ -4,5 +4,7 @@ FactoryGirl.define do factory :registrant_private_entity, class: Registrant, parent: :contact_private_entity factory :registrant_legal_entity, class: Registrant, parent: :contact_legal_entity + factory :registrant_with_address, class: Registrant, parent: :contact_with_address + factory :registrant_without_address, class: Registrant, parent: :contact_without_address end end diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb index a3f4a42c7..e05c5ad38 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -1,5 +1,59 @@ require 'rails_helper' RSpec.describe DomainMailer do + describe '#registrant_updated_notification_for_new_registrant', db: true do + subject(:message) { described_class.registrant_updated_notification_for_new_registrant(55, 55, 55, true) } + context 'when contact address processing is enabled' do + before :example do + allow(Contact).to receive(:address_processing?).and_return(true) + create(:domain, id: 55) + create(:registrant_with_address, id: 55) + end + + it 'sends message' do + expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + context 'when contact address processing is disabled' do + before :example do + allow(Contact).to receive(:address_processing?).and_return(false) + create(:domain, id: 55) + create(:registrant_without_address, id: 55) + end + + it 'sends message' do + expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + end + + describe '#registrant_updated_notification_for_old_registrant', db: true do + subject(:message) { described_class.registrant_updated_notification_for_old_registrant(55, 55, 55, true) } + + context 'when contact address processing is enabled' do + before :example do + allow(Contact).to receive(:address_processing?).and_return(true) + create(:domain, id: 55) + create(:registrant_with_address, id: 55) + end + + it 'sends message' do + expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + + context 'when contact address processing is disabled' do + before :example do + allow(Contact).to receive(:address_processing?).and_return(false) + create(:domain, id: 55) + create(:registrant_without_address, id: 55) + end + + it 'sends message' do + expect { message.deliver }.to change { ActionMailer::Base.deliveries.count }.by(1) + end + end + end end From 55571b39537b49b92a5a533423f8d35ef8a6e8e1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 5 Jan 2017 19:18:32 +0200 Subject: [PATCH 3/5] Fix factory lint spec #330 --- spec/factory_lint_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/factory_lint_spec.rb b/spec/factory_lint_spec.rb index 37988cca0..6269e3ec3 100644 --- a/spec/factory_lint_spec.rb +++ b/spec/factory_lint_spec.rb @@ -1,6 +1,10 @@ require_relative 'rails_helper' RSpec.describe 'FactoryGirl', db: true do + before :example do + allow(Contact).to receive(:address_processing?).and_return(false) + end + it 'lints factories' do FactoryGirl.lint end From 01c6804d2ab7894acb62d02f5d083d7ac3f87bbd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 6 Jan 2017 11:50:42 +0200 Subject: [PATCH 4/5] Do not show address in domain mailer unless address processing is disabled #330 --- app/mailers/domain_mailer.rb | 2 ++ ...trant_updated_notification_for_new_registrant.html.erb | 8 ++++++-- ...trant_updated_notification_for_new_registrant.text.erb | 8 ++++++-- ...trant_updated_notification_for_old_registrant.html.erb | 8 ++++++-- ...trant_updated_notification_for_old_registrant.text.erb | 8 ++++++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index bb8c55492..8c8c2d556 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -8,6 +8,7 @@ class DomainMailer < ApplicationMailer @old_registrant = Registrant.find(old_registrant_id) @new_registrant = Registrant.find(new_registrant_id) + @address_processing = Contact.address_processing? return if whitelist_blocked?(@new_registrant.email) mail(to: format(@new_registrant.email), @@ -23,6 +24,7 @@ class DomainMailer < ApplicationMailer @old_registrant = Registrant.find(old_registrant_id) @new_registrant = Registrant.find(new_registrant_id) + @address_processing = Contact.address_processing? return if whitelist_blocked?(@old_registrant.email) mail(to: format(@old_registrant.email), diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb index 07d55e11e..9797b18b3 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb @@ -10,9 +10,11 @@ Nimi: <%= @new_registrant.name %>
Äriregistrikood: <%= @new_registrant.ident %>
<% end %> Epost: <%= @new_registrant.email %>
+<% if @address_processing -%> Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
-Riik: <%= @new_registrant.country.try(:name) %> +Riik: <%= @new_registrant.country.name %> +<% end -%>

Lugupidamisega
Eesti Interneti Sihtasutus @@ -31,9 +33,11 @@ Name: <%= @new_registrant.name %>
Business Registry code: <%= @new_registrant.ident %>
<% end %> E-mail: <%= @new_registrant.email %>
+<% if @address_processing -%> Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
-Country: <%= @new_registrant.country.try(:name) %> +Country: <%= @new_registrant.country.name %> +<% end -%>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb index bd53aa535..fec027aaa 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb @@ -11,9 +11,11 @@ Nimi: <%= @new_registrant.name %> Äriregistrikood: <%= @new_registrant.ident %> <% end %> Epost: <%= @new_registrant.email %> +<% if @address_processing -%> Tänav: <%= @new_registrant.street %> Linn: <%= @new_registrant.city %> -Riik: <%= @new_registrant.country.try(:name) %> +Riik: <%= @new_registrant.country.name %> +<% end -%> Lugupidamisega Eesti Interneti Sihtasutus @@ -33,9 +35,11 @@ Name: <%= @new_registrant.name %> Business Registry code: <%= @new_registrant.ident %> <% end %> E-mail: <%= @new_registrant.email %> +<% if @address_processing -%> Street: <%= @new_registrant.street %> City: <%= @new_registrant.city %> -Country: <%= @new_registrant.country.try(:name) %> +Country: <%= @new_registrant.country.name %> +<% end -%> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index 3f0930d57..b1cf2ff7b 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -10,9 +10,11 @@ Isikukood: <%= @new_registrant.ident %>
Äriregistrikood: <%= @new_registrant.ident %>
<% end %> Epost: <%= @new_registrant.email %>
+<% if @address_processing -%> Tänav: <%= @new_registrant.street %>
Linn: <%= @new_registrant.city %>
-Riik: <%= @new_registrant.country.try(:name) %> +Riik: <%= @new_registrant.country.name %> +<% end -%>

Lugupidamisega
Eesti Interneti Sihtasutus @@ -31,9 +33,11 @@ Personal code: <%= @new_registrant.ident %>
Business Registry code: <%= @new_registrant.ident %>
<% end %> E-mail: <%= @new_registrant.email %>
+<% if @address_processing -%> Street: <%= @new_registrant.street %>
City: <%= @new_registrant.city %>
-Country: <%= @new_registrant.country.try(:name) %> +Country: <%= @new_registrant.country.name %> +<% end -%>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index 5bf78a409..5a333e662 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -11,9 +11,11 @@ Isikukood: <%= @new_registrant.ident %> Äriregistrikood: <%= @new_registrant.ident %> <% end %> Epost: <%= @new_registrant.email %> +<% if @address_processing -%> Tänav: <%= @new_registrant.street %> Linn: <%= @new_registrant.city %> -Riik: <%= @new_registrant.country.try(:name) %> +Riik: <%= @new_registrant.country.name %> +<% end -%> Lugupidamisega Eesti Interneti Sihtasutus @@ -33,9 +35,11 @@ Personal code: <%= @new_registrant.ident %> Business Registry code: <%= @new_registrant.ident %> <% end %> E-mail: <%= @new_registrant.email %> +<% if @address_processing -%> Street: <%= @new_registrant.street %> City: <%= @new_registrant.city %> -Country: <%= @new_registrant.country.try(:name) %> +Country: <%= @new_registrant.country.name %> +<% end -%> Best Regards, Estonian Internet Foundation From b75818edca11347ab9bfd7b10f67920e3d071336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 18 Jan 2017 17:04:30 +0200 Subject: [PATCH 5/5] Update contact.md create and update - specified fax number as unsupported element and postal address as optional --- doc/epp/contact.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/epp/contact.md b/doc/epp/contact.md index 9721f876f..dbfdc893f 100644 --- a/doc/epp/contact.md +++ b/doc/epp/contact.md @@ -25,13 +25,14 @@ More info: https://en.wikipedia.org/wiki/Latin_script_in_Unicode 1 Postal information container 1 Full name of the contact 0 Org is not supported and must be blank or missing - 1 Address container - 1-n Street name + 0-1 Address container, optional + 0-3 Street name 1 City name 0-1 State or province - 1 Postal code + 0-1 Postal code 1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2 1 Phone number in format \+ddd.d+ + 0 Fax is not supported and must be blank or missing 1 E-mail 1 1 Attribute: xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" @@ -60,12 +61,13 @@ More info: https://en.wikipedia.org/wiki/Latin_script_in_Unicode 0-1 Full name of the contact 0 Org is not supported and must be blank or missing 0-1 Address container - 0-n Street name - 0-1 City name + 0-3 Street name + 1 City name 0-1 State or province 0-1 Postal code - 0-1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2 + 1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2 0-1 Phone number in format \+ddd.d+ + 0 Fax is not supported and must be blank or missing 0-1 E-mail 0-1 Required if registrar is not the owner of the contact. 1 Contact password. Attribute: roid="String"