From 638167e3cb90a0276630cf02133841e237a342d6 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 3 Aug 2018 22:35:53 +0300 Subject: [PATCH 01/10] Improve registrant area --- .../stylesheets/registrant/registrant.sass | 4 +- .../registrant/contacts_controller.rb | 5 +++ app/views/registrant/contacts/show.html.erb | 6 +++ app/views/registrant/domains/_domain.html.erb | 5 ++- .../domains/partials/_admin_contacts.haml | 22 ---------- .../domains/partials/_contacts.html.erb | 40 +++++++++++++++++++ .../registrant/domains/partials/_owner.haml | 19 --------- .../domains/partials/_registrant.html.erb | 28 +++++++++++++ .../domains/partials/_tech_contacts.haml | 22 ---------- app/views/registrant/domains/show.html.erb | 24 +++++++++-- config/locales/contacts.en.yml | 3 ++ config/locales/registrant/contacts.en.yml | 2 + config/locales/registrant/domains.en.yml | 16 ++++---- config/routes.rb | 3 +- 14 files changed, 119 insertions(+), 80 deletions(-) delete mode 100644 app/views/registrant/domains/partials/_admin_contacts.haml create mode 100644 app/views/registrant/domains/partials/_contacts.html.erb delete mode 100644 app/views/registrant/domains/partials/_owner.haml create mode 100644 app/views/registrant/domains/partials/_registrant.html.erb delete mode 100644 app/views/registrant/domains/partials/_tech_contacts.haml diff --git a/app/assets/stylesheets/registrant/registrant.sass b/app/assets/stylesheets/registrant/registrant.sass index 6937c4b49..ebe9f4974 100644 --- a/app/assets/stylesheets/registrant/registrant.sass +++ b/app/assets/stylesheets/registrant/registrant.sass @@ -1,6 +1,7 @@ html position: relative min-height: 100% + overflow-y: scroll body padding-bottom: 130px @@ -30,9 +31,6 @@ h1, h2, h3, h4 color: white !important background-size: 100% -.semifooter - padding: 42px 0 80px 0 - .confirmation padding: 40px 0 20px 0 .column-keys diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb index 267b4d68d..4d0bed4d7 100644 --- a/app/controllers/registrant/contacts_controller.rb +++ b/app/controllers/registrant/contacts_controller.rb @@ -1,5 +1,6 @@ class Registrant::ContactsController < RegistrantController helper_method :domain_ids + helper_method :domain def show @contact = Contact.where(id: contacts).find_by(id: params[:id]) @@ -26,4 +27,8 @@ class Registrant::ContactsController < RegistrantController BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids end end + + def domain + Domain.find(params[:domain_id]) + end end diff --git a/app/views/registrant/contacts/show.html.erb b/app/views/registrant/contacts/show.html.erb index 6d08feccc..f9a8a86fa 100644 --- a/app/views/registrant/contacts/show.html.erb +++ b/app/views/registrant/contacts/show.html.erb @@ -1,3 +1,9 @@ + + diff --git a/app/views/registrant/domains/_domain.html.erb b/app/views/registrant/domains/_domain.html.erb index b3bf4d334..7228c9399 100644 --- a/app/views/registrant/domains/_domain.html.erb +++ b/app/views/registrant/domains/_domain.html.erb @@ -1,6 +1,9 @@ <%= link_to domain, registrant_domain_path(domain) %> - <%= link_to domain.registrant.name, registrant_contact_path(domain.registrant) %> + + <%= link_to domain.registrant.name, + registrant_domain_contact_path(domain, domain.registrant) %> + <%= l domain.expire_time %> <%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %> diff --git a/app/views/registrant/domains/partials/_admin_contacts.haml b/app/views/registrant/domains/partials/_admin_contacts.haml deleted file mode 100644 index 5ee50c31d..000000000 --- a/app/views/registrant/domains/partials/_admin_contacts.haml +++ /dev/null @@ -1,22 +0,0 @@ -- panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default' -.panel{class: panel_class} - .panel-heading.clearfix - = t('.title') - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-4'}= t(:name) - %th{class: 'col-xs-4'}= t(:id) - %th{class: 'col-xs-4'}= t(:email) - %tbody - - @domain.admin_contacts.each do |ac| - %tr - %td= link_to(ac, registrant_contact_path(ac)) - %td= ac.code - %td= ac.email - - if @domain.errors.messages[:admin_contacts] - %tfoot - - @domain.errors.messages[:admin_contacts].each do |x| - %tr - %td{colspan: 4}= x diff --git a/app/views/registrant/domains/partials/_contacts.html.erb b/app/views/registrant/domains/partials/_contacts.html.erb new file mode 100644 index 000000000..c66d364c3 --- /dev/null +++ b/app/views/registrant/domains/partials/_contacts.html.erb @@ -0,0 +1,40 @@ +<% panel_class = errors ? 'panel-danger' : 'panel-default' %> +
+
+ <%= header %> +
+ +
+ + + + + + + + + + + <% contacts.each do |contact| %> + + + + + + <% end %> + + + <% if errors %> + + <% errors.each do |error| %> + + + + <% end %> + + <% end %> +
<%= Contact.human_attribute_name :name %><%= Contact.human_attribute_name :code %><%= Contact.human_attribute_name :email %>
+ <%= link_to contact, registrant_domain_contact_path(domain, contact) %> + <%= contact.code %><%= contact.email %>
<%= error %>
+
+
\ No newline at end of file diff --git a/app/views/registrant/domains/partials/_owner.haml b/app/views/registrant/domains/partials/_owner.haml deleted file mode 100644 index 01bfa9ea9..000000000 --- a/app/views/registrant/domains/partials/_owner.haml +++ /dev/null @@ -1,19 +0,0 @@ -.panel.panel-default - .panel-heading - %h3.panel-title= t('.title') - .panel-body - %dl.dl-horizontal - %dt= t(:name) - %dd= link_to(@domain.registrant.name, registrant_contact_path(@domain.registrant)) - - %dt= t(:id) - %dd= @domain.registrant_code - - %dt= t(:identity_code) - %dd= @domain.registrant_ident - - %dt= t(:email) - %dd= @domain.registrant_email - - %dt= t(:phone) - %dd= @domain.registrant_phone diff --git a/app/views/registrant/domains/partials/_registrant.html.erb b/app/views/registrant/domains/partials/_registrant.html.erb new file mode 100644 index 000000000..67e0c91a4 --- /dev/null +++ b/app/views/registrant/domains/partials/_registrant.html.erb @@ -0,0 +1,28 @@ +
+
+ <%= t '.header' %> +
+ +
+
+
<%= Registrant.human_attribute_name :name %>
+
<%= registrant.name %>
+ +
<%= Registrant.human_attribute_name :code %>
+
<%= registrant.code %>
+ +
<%= Registrant.human_attribute_name :ident %>
+
<%= registrant.ident %>
+ +
<%= Registrant.human_attribute_name :email %>
+
<%= registrant.email %>
+ +
<%= Registrant.human_attribute_name :phone %>
+
<%= registrant.phone %>
+
+
+ + +
\ No newline at end of file diff --git a/app/views/registrant/domains/partials/_tech_contacts.haml b/app/views/registrant/domains/partials/_tech_contacts.haml deleted file mode 100644 index c1177ae4b..000000000 --- a/app/views/registrant/domains/partials/_tech_contacts.haml +++ /dev/null @@ -1,22 +0,0 @@ -- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default' -#tech_contacts.panel{class: panel_class} - .panel-heading.clearfix - = t('.title') - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-4'}= t(:name) - %th{class: 'col-xs-4'}= t(:id) - %th{class: 'col-xs-4'}= t(:email) - %tbody - - @domain.tech_contacts.each do |tc| - %tr - %td= link_to(tc, registrant_contact_path(tc)) - %td= tc.code - %td= tc.email - - if @domain.errors.messages[:tech_contacts] - %tfoot - - @domain.errors.messages[:tech_contacts].each do |x| - %tr - %td{colspan: 4}= x diff --git a/app/views/registrant/domains/show.html.erb b/app/views/registrant/domains/show.html.erb index 32dc2584a..fdbbc76cb 100644 --- a/app/views/registrant/domains/show.html.erb +++ b/app/views/registrant/domains/show.html.erb @@ -1,23 +1,39 @@ -<%= render 'shared/title', name: @domain.name %> + + +
<%= render 'registrant/domains/partials/general' %>
+
- <%= render 'registrant/domains/partials/owner' %> + <%= render partial: 'registrant/domains/partials/registrant', + locals: { registrant: @domain.registrant, domain: @domain } %>
- <%= render 'registrant/domains/partials/tech_contacts' %> + <%= render 'registrant/domains/partials/contacts', + header: t('.tech_contacts'), + domain: @domain, + contacts: @domain.tech_contacts, + errors: @domain.errors.messages[:tech_contacts] %>
- <%= render 'registrant/domains/partials/admin_contacts' %> + <%= render 'registrant/domains/partials/contacts', + header: t('.admin_contacts'), + domain: @domain, + contacts: @domain.admin_contacts, + errors: @domain.errors.messages[:admin_contacts] %>
diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml index 47589039b..13ab05f0f 100644 --- a/config/locales/contacts.en.yml +++ b/config/locales/contacts.en.yml @@ -5,6 +5,9 @@ en: registrant: Registrant admin_domain_contact: Administrative contact tech_domain_contact: Technical contact + attributes: + contact: + code: EPP Code errors: models: contact: diff --git a/config/locales/registrant/contacts.en.yml b/config/locales/registrant/contacts.en.yml index ef6ea173f..a44755832 100644 --- a/config/locales/registrant/contacts.en.yml +++ b/config/locales/registrant/contacts.en.yml @@ -1,6 +1,8 @@ en: registrant: contacts: + contact_index: Contacts + show: general: header: General diff --git a/config/locales/registrant/domains.en.yml b/config/locales/registrant/domains.en.yml index be0a1c638..ebb3d2aec 100644 --- a/config/locales/registrant/domains.en.yml +++ b/config/locales/registrant/domains.en.yml @@ -8,12 +8,12 @@ en: download_list: registrant: Registrant + + show: + admin_contacts: Administrative contacts + tech_contacts: Technical contacts + partials: - owner: - title: Registrant - - admin_contacts: - title: Admin. contacts - - tech_contacts: - title: Tech. contacts + registrant: + header: Registrant + view_details_btn: View details diff --git a/config/routes.rb b/config/routes.rb index 6af6623f8..9dd854ab3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,8 +113,9 @@ Rails.application.routes.draw do root 'domains#index' resources :registrars, only: :show - resources :contacts, only: :show resources :domains, only: %i[index show] do + resources :contacts, only: %i[show] + collection do get :download_list end From a2d3377f5e2c1c3bd66114e36afe813ed0715498 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 13 Aug 2018 11:37:10 +0300 Subject: [PATCH 02/10] Remove translation --- config/locales/contacts.en.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml index 13ab05f0f..47589039b 100644 --- a/config/locales/contacts.en.yml +++ b/config/locales/contacts.en.yml @@ -5,9 +5,6 @@ en: registrant: Registrant admin_domain_contact: Administrative contact tech_domain_contact: Technical contact - attributes: - contact: - code: EPP Code errors: models: contact: From ca5edb16fa1699e579ada9c42a8f3a0a98f27858 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 15 Aug 2018 12:56:56 +0300 Subject: [PATCH 03/10] Refactor contact list --- app/views/registrant/domains/_domain.html.erb | 2 +- app/views/registrant/domains/index.html.erb | 2 +- .../domains/partials/_domain_contact.html.erb | 7 +++++++ ...tacts.html.erb => _domain_contacts.html.erb} | 17 ++++++----------- app/views/registrant/domains/show.html.erb | 10 ++++------ config/locales/registrant/domains.en.yml | 8 ++++---- 6 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 app/views/registrant/domains/partials/_domain_contact.html.erb rename app/views/registrant/domains/partials/{_contacts.html.erb => _domain_contacts.html.erb} (69%) diff --git a/app/views/registrant/domains/_domain.html.erb b/app/views/registrant/domains/_domain.html.erb index 7228c9399..8cc8a490b 100644 --- a/app/views/registrant/domains/_domain.html.erb +++ b/app/views/registrant/domains/_domain.html.erb @@ -1,4 +1,4 @@ - + <%= link_to domain, registrant_domain_path(domain) %> <%= link_to domain.registrant.name, diff --git a/app/views/registrant/domains/index.html.erb b/app/views/registrant/domains/index.html.erb index 43a9122eb..acb9afcff 100644 --- a/app/views/registrant/domains/index.html.erb +++ b/app/views/registrant/domains/index.html.erb @@ -76,7 +76,7 @@
- +
+ + + + \ No newline at end of file diff --git a/app/views/registrant/domains/partials/_contacts.html.erb b/app/views/registrant/domains/partials/_domain_contacts.html.erb similarity index 69% rename from app/views/registrant/domains/partials/_contacts.html.erb rename to app/views/registrant/domains/partials/_domain_contacts.html.erb index c66d364c3..9b41288b7 100644 --- a/app/views/registrant/domains/partials/_contacts.html.erb +++ b/app/views/registrant/domains/partials/_domain_contacts.html.erb @@ -1,11 +1,12 @@ <% panel_class = errors ? 'panel-danger' : 'panel-default' %>
- <%= header %> + <%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
-
diff --git a/app/views/registrant/domains/partials/_domain_contact.html.erb b/app/views/registrant/domains/partials/_domain_contact.html.erb new file mode 100644 index 000000000..e4eaf7115 --- /dev/null +++ b/app/views/registrant/domains/partials/_domain_contact.html.erb @@ -0,0 +1,7 @@ +<% contact = domain_contact.contact %> + +
<%= link_to contact, registrant_domain_contact_path(domain, contact) %><%= contact.code %><%= contact.email %>
+
@@ -15,15 +16,9 @@ - <% contacts.each do |contact| %> - - - - - - <% end %> + <%= render partial: 'registrant/domains/partials/domain_contact', + collection: domain_contacts, + locals: { domain: domain } %> <% if errors %> diff --git a/app/views/registrant/domains/show.html.erb b/app/views/registrant/domains/show.html.erb index fdbbc76cb..88d238c7d 100644 --- a/app/views/registrant/domains/show.html.erb +++ b/app/views/registrant/domains/show.html.erb @@ -19,20 +19,18 @@
- <%= render 'registrant/domains/partials/contacts', - header: t('.tech_contacts'), + <%= render 'registrant/domains/partials/domain_contacts', domain: @domain, - contacts: @domain.tech_contacts, + domain_contacts: @domain.tech_domain_contacts, errors: @domain.errors.messages[:tech_contacts] %>
- <%= render 'registrant/domains/partials/contacts', - header: t('.admin_contacts'), + <%= render 'registrant/domains/partials/domain_contacts', domain: @domain, - contacts: @domain.admin_contacts, + domain_contacts: @domain.admin_domain_contacts, errors: @domain.errors.messages[:admin_contacts] %>
diff --git a/config/locales/registrant/domains.en.yml b/config/locales/registrant/domains.en.yml index ebb3d2aec..8df58239f 100644 --- a/config/locales/registrant/domains.en.yml +++ b/config/locales/registrant/domains.en.yml @@ -9,11 +9,11 @@ en: download_list: registrant: Registrant - show: - admin_contacts: Administrative contacts - tech_contacts: Technical contacts - partials: registrant: header: Registrant view_details_btn: View details + + domain_contacts: + header_admin_domain_contacts: Administrative contacts + header_tech_domain_contacts: Technical contacts From 5a466206bf5199ad265d29d9cbc7f539877939f1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 15 Aug 2018 12:57:15 +0300 Subject: [PATCH 04/10] Add registrant area tests --- test/fixtures/contacts.yml | 2 + test/fixtures/domains.yml | 6 +- .../registrant_area/contacts/details_test.rb | 27 +++++++++ .../registrant_area/domains/details_test.rb | 58 +++++++++++++++++++ .../registrant_area/domains/list_test.rb | 20 +++++++ 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 test/system/registrant_area/contacts/details_test.rb create mode 100644 test/system/registrant_area/domains/details_test.rb create mode 100644 test/system/registrant_area/domains/list_test.rb diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index 1f2e4b8da..4ae02105e 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -9,6 +9,8 @@ john: code: john-001 auth_info: cacb5b uuid: eb2f2766-b44c-4e14-9f16-32ab1a7cb957 + created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %> + updated_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %> william: &william name: William diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index 4d6468c92..5c4744e49 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -4,7 +4,11 @@ shop: registrar: bestnames registrant: john transfer_code: 65078d5 - valid_to: 2010-07-05 + registered_at: <%= Time.zone.parse('2010-07-04').to_s(:db) %> + valid_to: <%= Time.zone.parse('2010-07-05').to_s(:db) %> + outzone_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %> + delete_at: <%= Time.zone.parse('2010-07-07').to_s(:db) %> + force_delete_at: <%= Time.zone.parse('2010-07-08').to_s(:db) %> period: 1 period_unit: m uuid: 1b3ee442-e8fe-4922-9492-8fcb9dccc69c diff --git a/test/system/registrant_area/contacts/details_test.rb b/test/system/registrant_area/contacts/details_test.rb new file mode 100644 index 000000000..0f728a511 --- /dev/null +++ b/test/system/registrant_area/contacts/details_test.rb @@ -0,0 +1,27 @@ +require 'test_helper' + +class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase + setup do + sign_in users(:registrant) + @contact = contacts(:john) + + Setting.days_to_keep_business_registry_cache = 1 + travel_to Time.zone.parse('2010-07-05') + end + + def test_general_data + visit registrant_domain_contact_url(domains(:shop), @contact) + assert_text 'Code john-001' + assert_text 'Name John' + + assert_text 'Auth info' + assert_css('[value="cacb5b"]') + + assert_text 'Ident 1234' + assert_text 'Email john@inbox.test' + assert_text 'Phone +555.555' + + assert_text "Created at #{l Time.zone.parse('2010-07-05')}" + assert_text "Updated at #{l Time.zone.parse('2010-07-06')}" + end +end \ No newline at end of file diff --git a/test/system/registrant_area/domains/details_test.rb b/test/system/registrant_area/domains/details_test.rb new file mode 100644 index 000000000..57765844a --- /dev/null +++ b/test/system/registrant_area/domains/details_test.rb @@ -0,0 +1,58 @@ +require 'test_helper' + +class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase + setup do + sign_in users(:registrant) + @domain = domains(:shop) + + Setting.days_to_keep_business_registry_cache = 1 + travel_to Time.zone.parse('2010-07-05') + end + + def test_general_data + visit registrant_domain_url(@domain) + assert_text 'Name shop.test' + assert_text "Registered at #{l Time.zone.parse('2010-07-04')}" + assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar) + + assert_text 'Transfer code' + assert_css('[value="65078d5"]') + + assert_text "Valid to #{l Time.zone.parse('2010-07-05')}" + assert_text "Outzone at #{l Time.zone.parse('2010-07-06')}" + assert_text "Delete at #{l Time.zone.parse('2010-07-07')}" + assert_text "Force delete at #{l Time.zone.parse('2010-07-08')}" + end + + def test_registrant + visit registrant_domain_url(@domain) + assert_text 'Name John' + assert_text 'Code john-001' + assert_text 'Ident 1234' + assert_text 'Email john@inbox.test' + assert_text 'Phone +555.555' + assert_link 'View details', href: registrant_domain_contact_path(@domain, @domain.registrant) + end + + def test_admin_contacts + visit registrant_domain_url(@domain) + + within('.admin-domain-contacts') do + assert_link 'Jane', href: registrant_domain_contact_path(@domain, contacts(:jane)) + assert_text 'jane-001' + assert_text 'jane@mail.test' + assert_css '.admin-domain-contact', count: 1 + end + end + + def test_tech_contacts + visit registrant_domain_url(@domain) + + within('.tech-domain-contacts') do + assert_link 'William', href: registrant_domain_contact_path(@domain, contacts(:william)) + assert_text 'william-001' + assert_text 'william@inbox.test' + assert_css '.tech-domain-contact', count: 2 + end + end +end \ No newline at end of file diff --git a/test/system/registrant_area/domains/list_test.rb b/test/system/registrant_area/domains/list_test.rb new file mode 100644 index 000000000..6f2ddddff --- /dev/null +++ b/test/system/registrant_area/domains/list_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class RegistrantAreaDomainListTest < ApplicationSystemTestCase + setup do + sign_in users(:registrant) + @domain = domains(:shop) + + Setting.days_to_keep_business_registry_cache = 1 + travel_to Time.zone.parse('2010-07-05') + end + + def test_show_domain_list + visit registrant_domains_url + assert_link 'shop.test', href: registrant_domain_path(@domain) + assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant) + assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar) + assert_text l(Time.zone.parse('2010-07-05')) + assert_css '.domains .domain', count: 5 + end +end \ No newline at end of file From c89cce62877b30dac2ca4c478b2edaf62946f530 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 16 Aug 2018 14:49:12 +0300 Subject: [PATCH 05/10] Do not show contact if given domain does not belong to the current user --- app/controllers/registrant/contacts_controller.rb | 15 +++++++++++++-- test/fixtures/contacts.yml | 2 +- .../registrant/registrant_api_contacts_test.rb | 4 ++-- .../api/registrant/registrant_api_domains_test.rb | 2 +- .../registrant_area/contacts/details_test.rb | 8 ++++++++ .../registrant_area/domains/details_test.rb | 8 ++++++++ test/system/registrant_area/domains/list_test.rb | 7 ++++++- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb index 4d0bed4d7..7ce44b6a1 100644 --- a/app/controllers/registrant/contacts_controller.rb +++ b/app/controllers/registrant/contacts_controller.rb @@ -29,6 +29,17 @@ class Registrant::ContactsController < RegistrantController end def domain - Domain.find(params[:domain_id]) + current_user_domains.find(params[:domain_id]) end -end + + def current_user_domains + ident_cc, ident = @current_user.registrant_ident.split '-' + begin + BusinessRegistryCache.fetch_associated_domains ident, ident_cc + rescue Soap::Arireg::NotAvailableError => error + flash[:notice] = I18n.t(error.json[:message]) + Rails.logger.fatal("[EXCEPTION] #{error.to_s}") + current_user.domains + end + end +end \ No newline at end of file diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index 4ae02105e..ddefddf41 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -60,7 +60,7 @@ jack: name: Jack email: jack@inbox.test phone: '+555.555' - ident: 1234 + ident: 12345 ident_type: org registrar: goodnames ident_country_code: US diff --git a/test/integration/api/registrant/registrant_api_contacts_test.rb b/test/integration/api/registrant/registrant_api_contacts_test.rb index ddeaee9f3..97f0c8886 100644 --- a/test/integration/api/registrant/registrant_api_contacts_test.rb +++ b/test/integration/api/registrant/registrant_api_contacts_test.rb @@ -25,7 +25,7 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest assert_equal(200, response.status) json_body = JSON.parse(response.body, symbolize_names: true) - assert_equal(5, json_body.count) + assert_equal(4, json_body.count) array_of_contact_codes = json_body.map { |x| x[:code] } assert(array_of_contact_codes.include?('william-001')) assert(array_of_contact_codes.include?('jane-001')) @@ -39,7 +39,7 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest get '/api/v1/registrant/contacts', {}, @auth_headers response_json = JSON.parse(response.body, symbolize_names: true) - assert_equal(5, response_json.count) + assert_equal(4, response_json.count) end def test_get_contact_details_by_uuid diff --git a/test/integration/api/registrant/registrant_api_domains_test.rb b/test/integration/api/registrant/registrant_api_domains_test.rb index 128d15e20..0764db3aa 100644 --- a/test/integration/api/registrant/registrant_api_domains_test.rb +++ b/test/integration/api/registrant/registrant_api_domains_test.rb @@ -57,7 +57,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest get '/api/v1/registrant/domains', {}, @auth_headers response_json = JSON.parse(response.body, symbolize_names: true) - assert_equal(5, response_json.count) + assert_equal(4, response_json.count) end def test_root_does_not_accept_limit_higher_than_200 diff --git a/test/system/registrant_area/contacts/details_test.rb b/test/system/registrant_area/contacts/details_test.rb index 0f728a511..c63a7d58e 100644 --- a/test/system/registrant_area/contacts/details_test.rb +++ b/test/system/registrant_area/contacts/details_test.rb @@ -24,4 +24,12 @@ class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase assert_text "Created at #{l Time.zone.parse('2010-07-05')}" assert_text "Updated at #{l Time.zone.parse('2010-07-06')}" end + + def test_registrant_user_cannot_access_contact_when_given_domain_belongs_to_another_user + suppress(ActionView::Template::Error) do + visit registrant_domain_contact_url(domains(:metro), @contact) + assert_response :not_found + assert_no_text 'Name John' + end + end end \ No newline at end of file diff --git a/test/system/registrant_area/domains/details_test.rb b/test/system/registrant_area/domains/details_test.rb index 57765844a..afe94f937 100644 --- a/test/system/registrant_area/domains/details_test.rb +++ b/test/system/registrant_area/domains/details_test.rb @@ -55,4 +55,12 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase assert_css '.tech-domain-contact', count: 2 end end + + def test_registrant_user_cannot_access_domains_of_other_users + suppress(ActiveRecord::RecordNotFound) do + visit registrant_domain_url(domains(:metro)) + assert_response :not_found + assert_no_text 'metro.test' + end + end end \ No newline at end of file diff --git a/test/system/registrant_area/domains/list_test.rb b/test/system/registrant_area/domains/list_test.rb index 6f2ddddff..592cb7021 100644 --- a/test/system/registrant_area/domains/list_test.rb +++ b/test/system/registrant_area/domains/list_test.rb @@ -15,6 +15,11 @@ class RegistrantAreaDomainListTest < ApplicationSystemTestCase assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant) assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar) assert_text l(Time.zone.parse('2010-07-05')) - assert_css '.domains .domain', count: 5 + assert_css '.domains .domain', count: 4 + end + + def test_do_not_show_domains_of_other_registrant_users + visit registrant_domains_url + assert_no_text 'metro.test' end end \ No newline at end of file From 8f0f23606c094a02e061fc07a3de04fd2a684b5d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 17 Aug 2018 22:23:54 +0300 Subject: [PATCH 06/10] Remove unused and buggy code --- .../domains/partials/_domain_contacts.html.erb | 13 +------------ app/views/registrant/domains/show.html.erb | 6 ++---- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/views/registrant/domains/partials/_domain_contacts.html.erb b/app/views/registrant/domains/partials/_domain_contacts.html.erb index 9b41288b7..3876e2546 100644 --- a/app/views/registrant/domains/partials/_domain_contacts.html.erb +++ b/app/views/registrant/domains/partials/_domain_contacts.html.erb @@ -1,5 +1,4 @@ -<% panel_class = errors ? 'panel-danger' : 'panel-default' %> -
+
<%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
@@ -20,16 +19,6 @@ collection: domain_contacts, locals: { domain: domain } %> - - <% if errors %> -
- <% errors.each do |error| %> - - - - <% end %> - - <% end %>
<%= Contact.human_attribute_name :name %>
- <%= link_to contact, registrant_domain_contact_path(domain, contact) %> - <%= contact.code %><%= contact.email %>
<%= error %>
\ No newline at end of file diff --git a/app/views/registrant/domains/show.html.erb b/app/views/registrant/domains/show.html.erb index 88d238c7d..d09253b6b 100644 --- a/app/views/registrant/domains/show.html.erb +++ b/app/views/registrant/domains/show.html.erb @@ -21,8 +21,7 @@
<%= render 'registrant/domains/partials/domain_contacts', domain: @domain, - domain_contacts: @domain.tech_domain_contacts, - errors: @domain.errors.messages[:tech_contacts] %> + domain_contacts: @domain.tech_domain_contacts %>
@@ -30,8 +29,7 @@
<%= render 'registrant/domains/partials/domain_contacts', domain: @domain, - domain_contacts: @domain.admin_domain_contacts, - errors: @domain.errors.messages[:admin_contacts] %> + domain_contacts: @domain.admin_domain_contacts %>
From 034e8e9d117156402ae099eded7d175a0e27a7d2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 27 Aug 2018 12:27:45 +0300 Subject: [PATCH 07/10] Integrate master --- app/controllers/registrant/contacts_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb index 793b84451..b2ebad344 100644 --- a/app/controllers/registrant/contacts_controller.rb +++ b/app/controllers/registrant/contacts_controller.rb @@ -32,13 +32,13 @@ class Registrant::ContactsController < RegistrantController end def current_user_domains - ident_cc, ident = @current_user.registrant_ident.split '-' + ident_cc, ident = current_registrant_user.registrant_ident.split '-' begin BusinessRegistryCache.fetch_associated_domains ident, ident_cc rescue Soap::Arireg::NotAvailableError => error flash[:notice] = I18n.t(error.json[:message]) Rails.logger.fatal("[EXCEPTION] #{error.to_s}") - current_user.domains + current_registrant_user.domains end end end \ No newline at end of file From d9526c6f3a06b937ab3a86533f7345dd53258f20 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 18 Sep 2018 13:30:29 +0300 Subject: [PATCH 08/10] Restore old UI --- .../registrant/domains/partials/_registrant.html.erb | 8 +++----- config/locales/registrant/domains.en.yml | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/registrant/domains/partials/_registrant.html.erb b/app/views/registrant/domains/partials/_registrant.html.erb index 67e0c91a4..f02a2eb4e 100644 --- a/app/views/registrant/domains/partials/_registrant.html.erb +++ b/app/views/registrant/domains/partials/_registrant.html.erb @@ -6,7 +6,9 @@
<%= Registrant.human_attribute_name :name %>
-
<%= registrant.name %>
+
+ <%= link_to registrant.name, registrant_domain_contact_path(domain, registrant) %> +
<%= Registrant.human_attribute_name :code %>
<%= registrant.code %>
@@ -21,8 +23,4 @@
<%= registrant.phone %>
- - \ No newline at end of file diff --git a/config/locales/registrant/domains.en.yml b/config/locales/registrant/domains.en.yml index 8df58239f..5016f3f4e 100644 --- a/config/locales/registrant/domains.en.yml +++ b/config/locales/registrant/domains.en.yml @@ -12,7 +12,6 @@ en: partials: registrant: header: Registrant - view_details_btn: View details domain_contacts: header_admin_domain_contacts: Administrative contacts From cabf92253da082454b7f91e00b07d2be9035224d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 18 Sep 2018 13:31:28 +0300 Subject: [PATCH 09/10] Use default translation --- app/views/registrant/domains/partials/_general.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb index 5dff93331..46d55bd85 100644 --- a/app/views/registrant/domains/partials/_general.html.erb +++ b/app/views/registrant/domains/partials/_general.html.erb @@ -13,7 +13,7 @@
<%= t(:registered_at) %>
<%= l(@domain.registered_at) %>
-
<%= t(:registrar_name) %>
+
<%= Registrar.model_name.human %>
<%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %>
<%= Domain.human_attribute_name :transfer_code %>
From e4db808711653a24c70562191be77c2de4d806dc Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 18 Sep 2018 13:53:52 +0300 Subject: [PATCH 10/10] Fix test --- test/system/registrant_area/domains/details_test.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/system/registrant_area/domains/details_test.rb b/test/system/registrant_area/domains/details_test.rb index afe94f937..de3db7e7d 100644 --- a/test/system/registrant_area/domains/details_test.rb +++ b/test/system/registrant_area/domains/details_test.rb @@ -26,12 +26,11 @@ class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase def test_registrant visit registrant_domain_url(@domain) - assert_text 'Name John' + assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant) assert_text 'Code john-001' assert_text 'Ident 1234' assert_text 'Email john@inbox.test' assert_text 'Phone +555.555' - assert_link 'View details', href: registrant_domain_contact_path(@domain, @domain.registrant) end def test_admin_contacts