From 638167e3cb90a0276630cf02133841e237a342d6 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 3 Aug 2018 22:35:53 +0300 Subject: [PATCH 01/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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 ba08856953e0f79d7691c539a27c73f52b79f5ec Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 22 Aug 2018 19:32:12 +0300 Subject: [PATCH 07/37] Improve EPP poll tests --- test/fixtures/messages.yml | 11 +++ test/integration/epp/poll_test.rb | 108 +++++++++++++++++++++++++----- test/models/message_test.rb | 8 ++- 3 files changed, 108 insertions(+), 19 deletions(-) diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml index 47cbdd0f2..58ae3bd6d 100644 --- a/test/fixtures/messages.yml +++ b/test/fixtures/messages.yml @@ -2,3 +2,14 @@ greeting: body: Welcome! queued: true registrar: bestnames + +domain_deleted: + body: Your domain has been deleted + queued: true + registrar: bestnames + created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %> + +farewell: + body: Good bye! + queued: true + registrar: goodnames \ No newline at end of file diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 30ee5c769..d79ed28d6 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -1,24 +1,11 @@ require 'test_helper' class EppPollTest < ApplicationIntegrationTest - def test_messages - post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' } - assert_equal '1301', Nokogiri::XML(response.body).at_css('result')[:code] - assert_equal 1, Nokogiri::XML(response.body).css('msgQ').size - assert_equal 1, Nokogiri::XML(response.body).css('result').size - end + def test_return_first_message_when_queue_is_not_empty + message = messages(:domain_deleted) - def test_no_messages - registrars(:bestnames).messages.delete_all(:delete_all) - post '/epp/command/poll', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' } - assert_equal '1300', Nokogiri::XML(response.body).at_css('result')[:code] - assert_equal 1, Nokogiri::XML(response.body).css('result').size - end - - private - - def request_xml - <<-XML + request_xml = + <<-XML @@ -26,5 +13,90 @@ class EppPollTest < ApplicationIntegrationTest XML + post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' + response_xml = Nokogiri::XML(response.body) + + assert_equal 1301.to_s, response_xml.at_css('result')[:code] + assert_equal 1, response_xml.css('result').size + assert_equal 2.to_s, response_xml.at_css('msgQ')[:count] + assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id] + assert_equal Time.zone.parse('2010-07-05').iso8601, response_xml.at_css('msgQ qDate').text + assert_equal 'Your domain has been deleted', response_xml.at_css('msgQ msg').text end -end + + def test_no_messages_in_queue + registrars(:bestnames).messages.delete_all(:delete_all) + + request_xml = + <<-XML + + + + + + + XML + post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' + response_xml = Nokogiri::XML(response.body) + + assert_equal 1300.to_s, response_xml.at_css('result')[:code] + assert_equal 1, response_xml.css('result').size + end + + def test_dequeue_message + message = messages(:greeting) + + request_xml = <<-XML + + + + + + + XML + + post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' + message.reload + response_xml = Nokogiri::XML(response.body) + + assert_not message.queued? + assert_equal 1000.to_s, response_xml.at_css('result')[:code] + assert_equal 1, response_xml.css('result').size + assert_equal 1.to_s, response_xml.at_css('msgQ')[:count] + assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id] + end + + def test_message_of_other_registrars_cannot_be_dequeued + message = messages(:farewell) + + request_xml = <<-XML + + + + + + + XML + post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' + response_xml = Nokogiri::XML(response.body) + message.reload + + assert message.queued? + assert_equal 2303.to_s, response_xml.at_css('result')[:code] + end + + def test_message_not_found + request_xml = <<-XML + + + + + + + XML + post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' + response_xml = Nokogiri::XML(response.body) + + assert_equal 2303.to_s, response_xml.at_css('result')[:code] + end +end \ No newline at end of file diff --git a/test/models/message_test.rb b/test/models/message_test.rb index 5c557150d..ba2203d8a 100644 --- a/test/models/message_test.rb +++ b/test/models/message_test.rb @@ -18,4 +18,10 @@ class MessageTest < ActiveSupport::TestCase @message.registrar = nil assert @message.invalid? end -end + + def test_dequeue + @message.dequeue + @message.reload + assert_not @message.queued? + end +end \ No newline at end of file From 9852b466cf0c0108c470fdbf4b4ea772db257f78 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 23 Aug 2018 14:20:04 +0300 Subject: [PATCH 08/37] Add clarification --- test/integration/epp/poll_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index d79ed28d6..2cf5c4254 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -1,7 +1,8 @@ require 'test_helper' class EppPollTest < ApplicationIntegrationTest - def test_return_first_message_when_queue_is_not_empty + # Deliberately does not conform to RFC5730, which requires the first message to be returned + def test_return_latest_message_when_queue_is_not_empty message = messages(:domain_deleted) request_xml = From 8765baf319212916fdc32a587b550138b5da9053 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 23 Aug 2018 20:03:03 +0300 Subject: [PATCH 09/37] Rename Message to Notification --- .../admin/domains/force_delete_controller.rb | 3 +- app/controllers/epp/polls_controller.rb | 18 +- app/jobs/domain_delete_confirm_job.rb | 4 +- app/jobs/domain_delete_job.rb | 2 +- app/jobs/domain_update_confirm_job.rb | 4 +- app/models/api_user.rb | 4 +- app/models/domain.rb | 4 +- app/models/domain_transfer.rb | 4 +- app/models/epp/domain.rb | 4 +- app/models/{message.rb => notification.rb} | 4 +- app/models/registrar.rb | 2 +- app/models/version/message_version.rb | 5 - app/models/version/notification_version.rb | 5 + app/views/epp/poll/poll_ack.xml.builder | 2 +- app/views/epp/poll/poll_keyrelay.xml.builder | 6 +- app/views/epp/poll/poll_req.xml.builder | 8 +- config/locales/en.yml | 1 - .../{messages.en.yml => notifications.en.yml} | 2 +- ...161237_rename_messages_to_notifications.rb | 5 + ...ename_log_messages_to_log_notifications.rb | 5 + db/structure.sql | 238 +++++++++--------- spec/models/domain_spec.rb | 6 +- .../{messages.yml => notifications.yml} | 0 test/integration/api/domain_transfers_test.rb | 2 +- .../epp/domain/transfer/request_test.rb | 2 +- test/integration/epp/poll_test.rb | 34 +-- test/jobs/domain_delete_confirm_job_test.rb | 16 +- test/jobs/domain_update_confirm_job_test.rb | 16 +- test/models/domain_transfer_test.rb | 10 +- test/models/message_test.rb | 27 -- test/models/notification_test.rb | 27 ++ .../admin_area/domains/force_delete_test.rb | 2 +- 32 files changed, 243 insertions(+), 229 deletions(-) rename app/models/{message.rb => notification.rb} (72%) delete mode 100644 app/models/version/message_version.rb create mode 100644 app/models/version/notification_version.rb rename config/locales/{messages.en.yml => notifications.en.yml} (92%) create mode 100644 db/migrate/20180823161237_rename_messages_to_notifications.rb create mode 100644 db/migrate/20180823163548_rename_log_messages_to_log_notifications.rb rename test/fixtures/{messages.yml => notifications.yml} (100%) delete mode 100644 test/models/message_test.rb create mode 100644 test/models/notification_test.rb diff --git a/app/controllers/admin/domains/force_delete_controller.rb b/app/controllers/admin/domains/force_delete_controller.rb index 5d72739d5..155b4fa41 100644 --- a/app/controllers/admin/domains/force_delete_controller.rb +++ b/app/controllers/admin/domains/force_delete_controller.rb @@ -6,7 +6,8 @@ module Admin domain.transaction do domain.schedule_force_delete - domain.registrar.messages.create!(body: t('force_delete_set_on_domain', domain_name: domain.name)) + domain.registrar.notifications.create!(body: t('force_delete_set_on_domain', + domain_name: domain.name)) if notify_by_email? DomainDeleteMailer.forced(domain: domain, diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb index 44f8afdc1..ef41bfaf7 100644 --- a/app/controllers/epp/polls_controller.rb +++ b/app/controllers/epp/polls_controller.rb @@ -9,12 +9,12 @@ class Epp::PollsController < EppController private def req_poll - @message = current_user.queued_messages.last + @notification = current_user.queued_notifications.last - render_epp_response 'epp/poll/poll_no_messages' and return unless @message - if @message.attached_obj_type && @message.attached_obj_id + render_epp_response 'epp/poll/poll_no_messages' and return unless @notification + if @notification.attached_obj_type && @notification.attached_obj_id begin - @object = Object.const_get(@message.attached_obj_type).find(@message.attached_obj_id) + @object = Object.const_get(@notification.attached_obj_type).find(@notification.attached_obj_id) rescue => problem # the data model might be inconsistent; or ... # this could happen if the registrar does not dequeue messages, and then the domain was deleted @@ -28,7 +28,7 @@ class Epp::PollsController < EppController end end - if @message.attached_obj_type == 'Keyrelay' + if @notification.attached_obj_type == 'Keyrelay' render_epp_response 'epp/poll/poll_keyrelay' else render_epp_response 'epp/poll/poll_req' @@ -36,9 +36,9 @@ class Epp::PollsController < EppController end def ack_poll - @message = current_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID']) + @notification = current_user.queued_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID']) - unless @message + unless @notification epp_errors << { code: '2303', msg: I18n.t('message_was_not_found'), @@ -47,7 +47,7 @@ class Epp::PollsController < EppController handle_errors and return end - handle_errors(@message) and return unless @message.dequeue + handle_errors(@notification) and return unless @notification.dequeue render_epp_response 'epp/poll/poll_ack' end @@ -56,6 +56,6 @@ class Epp::PollsController < EppController end def resource - @message + @notification end end diff --git a/app/jobs/domain_delete_confirm_job.rb b/app/jobs/domain_delete_confirm_job.rb index 3cc13bcd3..28a46dbbe 100644 --- a/app/jobs/domain_delete_confirm_job.rb +++ b/app/jobs/domain_delete_confirm_job.rb @@ -7,13 +7,13 @@ class DomainDeleteConfirmJob < Que::Job case action when RegistrantVerification::CONFIRMED - domain.poll_message!(:poll_pending_delete_confirmed_by_registrant) + domain.notify_registrar(:poll_pending_delete_confirmed_by_registrant) domain.apply_pending_delete! raise_errors!(domain) when RegistrantVerification::REJECTED domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) - domain.poll_message!(:poll_pending_delete_rejected_by_registrant) + domain.notify_registrar(:poll_pending_delete_rejected_by_registrant) domain.cancel_pending_delete domain.save(validate: false) diff --git a/app/jobs/domain_delete_job.rb b/app/jobs/domain_delete_job.rb index 7d86e9885..15195b588 100644 --- a/app/jobs/domain_delete_job.rb +++ b/app/jobs/domain_delete_job.rb @@ -8,7 +8,7 @@ class DomainDeleteJob < Que::Job domain.destroy bye_bye = domain.versions.last - domain.registrar.messages.create!( + domain.registrar.notifications.create!( body: "#{I18n.t(:domain_deleted)}: #{domain.name}", attached_obj_id: bye_bye.id, attached_obj_type: bye_bye.class.to_s diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index c661c7b6b..376858c42 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -8,7 +8,7 @@ class DomainUpdateConfirmJob < Que::Job case action when RegistrantVerification::CONFIRMED old_registrant = domain.registrant - domain.poll_message!(:poll_pending_update_confirmed_by_registrant) + domain.notify_registrar(:poll_pending_update_confirmed_by_registrant) raise_errors!(domain) domain.apply_pending_update! @@ -22,7 +22,7 @@ class DomainUpdateConfirmJob < Que::Job registrar: domain.registrar, registrant: domain.registrant).deliver_now - domain.poll_message!(:poll_pending_update_rejected_by_registrant) + domain.notify_registrar(:poll_pending_update_rejected_by_registrant) domain.preclean_pendings domain.clean_pendings! diff --git a/app/models/api_user.rb b/app/models/api_user.rb index ce32c4045..8d5018568 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -79,8 +79,8 @@ class ApiUser < User username end - def queued_messages - registrar.messages.queued + def queued_notifications + registrar.notifications.queued end def registrar_pki_ok?(crt, cn) diff --git a/app/models/domain.rb b/app/models/domain.rb index 33f8a8f09..d39e86272 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -270,8 +270,8 @@ class Domain < ActiveRecord::Base true end - def poll_message!(message_key) - registrar.messages.create!( + def notify_registrar(message_key) + registrar.notifications.create!( body: "#{I18n.t(message_key)}: #{name}", attached_obj_id: id, attached_obj_type: self.class.to_s diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 6982f36b6..2ac35a0db 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -73,8 +73,8 @@ class DomainTransfer < ActiveRecord::Base old_contacts_codes = domain.contacts.pluck(:code).sort.uniq.join(', ') old_registrant_code = domain.registrant.code - old_registrar.messages.create!( - body: I18n.t('messages.texts.domain_transfer', + old_registrar.notifications.create!( + body: I18n.t('notifications.texts.domain_transfer', domain_name: domain.name, old_contacts_codes: old_contacts_codes, old_registrant_code: old_registrant_code), diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 749f5310c..2bfd10215 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -625,7 +625,7 @@ class Epp::Domain < Domain ) if dt.pending? - registrar.messages.create!( + registrar.notifications.create!( body: I18n.t('transfer_requested'), attached_obj_id: dt.id, attached_obj_type: dt.class.to_s @@ -727,7 +727,7 @@ class Epp::Domain < Domain return false unless valid? - registrar.messages.create!( + registrar.notifications.create!( body: 'Key Relay action completed successfully.', attached_obj_type: kr.class.to_s, attached_obj_id: kr.id diff --git a/app/models/message.rb b/app/models/notification.rb similarity index 72% rename from app/models/message.rb rename to app/models/notification.rb index 1f01842c8..09f9377da 100644 --- a/app/models/message.rb +++ b/app/models/notification.rb @@ -1,5 +1,5 @@ -class Message < ActiveRecord::Base - include Versions # version/message_version.rb +class Notification < ActiveRecord::Base + include Versions # version/notification_version.rb belongs_to :registrar, required: true before_create -> { self.queued = true } diff --git a/app/models/registrar.rb b/app/models/registrar.rb index de02d42a7..611dfc562 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -4,7 +4,7 @@ class Registrar < ActiveRecord::Base has_many :domains, dependent: :restrict_with_error has_many :contacts, dependent: :restrict_with_error has_many :api_users, dependent: :restrict_with_error - has_many :messages + has_many :notifications has_many :invoices, foreign_key: 'buyer_id' has_many :accounts, dependent: :destroy has_many :nameservers, through: :domains diff --git a/app/models/version/message_version.rb b/app/models/version/message_version.rb deleted file mode 100644 index 548c11dd6..000000000 --- a/app/models/version/message_version.rb +++ /dev/null @@ -1,5 +0,0 @@ -class MessageVersion < PaperTrail::Version - include VersionSession - self.table_name = :log_messages - self.sequence_name = :log_messages_id_seq -end diff --git a/app/models/version/notification_version.rb b/app/models/version/notification_version.rb new file mode 100644 index 000000000..0b66aabe5 --- /dev/null +++ b/app/models/version/notification_version.rb @@ -0,0 +1,5 @@ +class NotificationVersion < PaperTrail::Version + include VersionSession + self.table_name = :log_notifications + self.sequence_name = :log_notifications_id_seq +end diff --git a/app/views/epp/poll/poll_ack.xml.builder b/app/views/epp/poll/poll_ack.xml.builder index 05ea8b8d0..1ee6fa315 100644 --- a/app/views/epp/poll/poll_ack.xml.builder +++ b/app/views/epp/poll/poll_ack.xml.builder @@ -4,7 +4,7 @@ xml.epp_head do xml.msg 'Command completed successfully' end - xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) + xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) render('epp/shared/trID', builder: xml) end diff --git a/app/views/epp/poll/poll_keyrelay.xml.builder b/app/views/epp/poll/poll_keyrelay.xml.builder index 7c2ca6c5a..c79b2a574 100644 --- a/app/views/epp/poll/poll_keyrelay.xml.builder +++ b/app/views/epp/poll/poll_keyrelay.xml.builder @@ -10,9 +10,9 @@ xml.epp( xml.msg 'Command completed successfully; ack to dequeue' end - xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do - xml.qDate @message.created_at.try(:iso8601) - xml.msg @message.body + xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do + xml.qDate @notification.created_at.try(:iso8601) + xml.msg @notification.body end xml.resData do diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index d5da707a6..f483e017b 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -4,12 +4,12 @@ xml.epp_head do xml.msg 'Command completed successfully; ack to dequeue' end - xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do - xml.qDate @message.created_at.try(:iso8601) - xml.msg @message.body + xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do + xml.qDate @notification.created_at.try(:iso8601) + xml.msg @notification.body end - if @message.attached_obj_type == 'DomainTransfer' + if @notification.attached_obj_type == 'DomainTransfer' xml.resData do xml << render('epp/domains/partials/transfer', builder: xml, dt: @object) end if @object diff --git a/config/locales/en.yml b/config/locales/en.yml index 2afbb45a5..dbdfb3f0c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -486,7 +486,6 @@ en: message: 'Message' message_no: 'Message #%{id}' queue_date: 'Queue date' - messages_in_queue: 'Messages in queue' you_have_no_new_messages: 'You have no new messages' message_id: 'Message ID' trStatus: 'Status' diff --git a/config/locales/messages.en.yml b/config/locales/notifications.en.yml similarity index 92% rename from config/locales/messages.en.yml rename to config/locales/notifications.en.yml index 0c85bb49c..46e03c689 100644 --- a/config/locales/messages.en.yml +++ b/config/locales/notifications.en.yml @@ -1,5 +1,5 @@ en: - messages: + notifications: texts: domain_transfer: >- Transfer of domain %{domain_name} has been approved. diff --git a/db/migrate/20180823161237_rename_messages_to_notifications.rb b/db/migrate/20180823161237_rename_messages_to_notifications.rb new file mode 100644 index 000000000..ecd0e9b1e --- /dev/null +++ b/db/migrate/20180823161237_rename_messages_to_notifications.rb @@ -0,0 +1,5 @@ +class RenameMessagesToNotifications < ActiveRecord::Migration + def change + rename_table :messages, :notifications + end +end diff --git a/db/migrate/20180823163548_rename_log_messages_to_log_notifications.rb b/db/migrate/20180823163548_rename_log_messages_to_log_notifications.rb new file mode 100644 index 000000000..70dcbf50a --- /dev/null +++ b/db/migrate/20180823163548_rename_log_messages_to_log_notifications.rb @@ -0,0 +1,5 @@ +class RenameLogMessagesToLogNotifications < ActiveRecord::Migration + def change + rename_table :log_messages, :log_notifications + end +end diff --git a/db/structure.sql b/db/structure.sql index 3bd6939f6..d1f6adb36 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1651,44 +1651,6 @@ CREATE SEQUENCE public.log_keyrelays_id_seq ALTER SEQUENCE public.log_keyrelays_id_seq OWNED BY public.log_keyrelays.id; --- --- Name: log_messages; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE public.log_messages ( - id integer NOT NULL, - item_type character varying NOT NULL, - item_id integer NOT NULL, - event character varying NOT NULL, - whodunnit character varying, - object json, - object_changes json, - created_at timestamp without time zone, - session character varying, - children json, - uuid character varying -); - - --- --- Name: log_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.log_messages_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: log_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.log_messages_id_seq OWNED BY public.log_messages.id; - - -- -- Name: log_nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -1727,6 +1689,44 @@ CREATE SEQUENCE public.log_nameservers_id_seq ALTER SEQUENCE public.log_nameservers_id_seq OWNED BY public.log_nameservers.id; +-- +-- Name: log_notifications; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE public.log_notifications ( + id integer NOT NULL, + item_type character varying NOT NULL, + item_id integer NOT NULL, + event character varying NOT NULL, + whodunnit character varying, + object json, + object_changes json, + created_at timestamp without time zone, + session character varying, + children json, + uuid character varying +); + + +-- +-- Name: log_notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.log_notifications_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: log_notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.log_notifications_id_seq OWNED BY public.log_notifications.id; + + -- -- Name: log_registrars; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -1954,43 +1954,6 @@ CREATE SEQUENCE public.mail_templates_id_seq ALTER SEQUENCE public.mail_templates_id_seq OWNED BY public.mail_templates.id; --- --- Name: messages; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE public.messages ( - id integer NOT NULL, - registrar_id integer NOT NULL, - body character varying NOT NULL, - attached_obj_type character varying, - attached_obj_id integer, - queued boolean, - created_at timestamp without time zone, - updated_at timestamp without time zone, - creator_str character varying, - updator_str character varying -); - - --- --- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.messages_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id; - - -- -- Name: nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2029,6 +1992,43 @@ CREATE SEQUENCE public.nameservers_id_seq ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id; +-- +-- Name: notifications; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE public.notifications ( + id integer NOT NULL, + registrar_id integer NOT NULL, + body character varying NOT NULL, + attached_obj_type character varying, + attached_obj_id integer, + queued boolean, + created_at timestamp without time zone, + updated_at timestamp without time zone, + creator_str character varying, + updator_str character varying +); + + +-- +-- Name: notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.notifications_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id; + + -- -- Name: prices; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2714,14 +2714,14 @@ ALTER TABLE ONLY public.log_keyrelays ALTER COLUMN id SET DEFAULT nextval('publi -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.log_messages ALTER COLUMN id SET DEFAULT nextval('public.log_messages_id_seq'::regclass); +ALTER TABLE ONLY public.log_nameservers ALTER COLUMN id SET DEFAULT nextval('public.log_nameservers_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.log_nameservers ALTER COLUMN id SET DEFAULT nextval('public.log_nameservers_id_seq'::regclass); +ALTER TABLE ONLY public.log_notifications ALTER COLUMN id SET DEFAULT nextval('public.log_notifications_id_seq'::regclass); -- @@ -2770,14 +2770,14 @@ ALTER TABLE ONLY public.mail_templates ALTER COLUMN id SET DEFAULT nextval('publ -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass); +ALTER TABLE ONLY public.nameservers ALTER COLUMN id SET DEFAULT nextval('public.nameservers_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.nameservers ALTER COLUMN id SET DEFAULT nextval('public.nameservers_id_seq'::regclass); +ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass); -- @@ -3129,14 +3129,6 @@ ALTER TABLE ONLY public.log_keyrelays ADD CONSTRAINT log_keyrelays_pkey PRIMARY KEY (id); --- --- Name: log_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY public.log_messages - ADD CONSTRAINT log_messages_pkey PRIMARY KEY (id); - - -- -- Name: log_nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3145,6 +3137,14 @@ ALTER TABLE ONLY public.log_nameservers ADD CONSTRAINT log_nameservers_pkey PRIMARY KEY (id); +-- +-- Name: log_notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY public.log_notifications + ADD CONSTRAINT log_notifications_pkey PRIMARY KEY (id); + + -- -- Name: log_registrars_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3193,14 +3193,6 @@ ALTER TABLE ONLY public.mail_templates ADD CONSTRAINT mail_templates_pkey PRIMARY KEY (id); --- --- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY public.messages - ADD CONSTRAINT messages_pkey PRIMARY KEY (id); - - -- -- Name: nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3209,6 +3201,14 @@ ALTER TABLE ONLY public.nameservers ADD CONSTRAINT nameservers_pkey PRIMARY KEY (id); +-- +-- Name: notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT notifications_pkey PRIMARY KEY (id); + + -- -- Name: prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3788,20 +3788,6 @@ CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON public.log_keyrelay CREATE INDEX index_log_keyrelays_on_whodunnit ON public.log_keyrelays USING btree (whodunnit); --- --- Name: index_log_messages_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_messages_on_item_type_and_item_id ON public.log_messages USING btree (item_type, item_id); - - --- --- Name: index_log_messages_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_messages_on_whodunnit ON public.log_messages USING btree (whodunnit); - - -- -- Name: index_log_nameservers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -3816,6 +3802,20 @@ CREATE INDEX index_log_nameservers_on_item_type_and_item_id ON public.log_namese CREATE INDEX index_log_nameservers_on_whodunnit ON public.log_nameservers USING btree (whodunnit); +-- +-- Name: index_log_notifications_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_log_notifications_on_item_type_and_item_id ON public.log_notifications USING btree (item_type, item_id); + + +-- +-- Name: index_log_notifications_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_log_notifications_on_whodunnit ON public.log_notifications USING btree (whodunnit); + + -- -- Name: index_log_registrars_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -3872,13 +3872,6 @@ CREATE INDEX index_log_users_on_item_type_and_item_id ON public.log_users USING CREATE INDEX index_log_users_on_whodunnit ON public.log_users USING btree (whodunnit); --- --- Name: index_messages_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_messages_on_registrar_id ON public.messages USING btree (registrar_id); - - -- -- Name: index_nameservers_on_domain_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -3886,6 +3879,13 @@ CREATE INDEX index_messages_on_registrar_id ON public.messages USING btree (regi CREATE INDEX index_nameservers_on_domain_id ON public.nameservers USING btree (domain_id); +-- +-- Name: index_notifications_on_registrar_id; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING btree (registrar_id); + + -- -- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4101,7 +4101,7 @@ ALTER TABLE ONLY public.account_activities -- Name: messages_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.messages +ALTER TABLE ONLY public.notifications ADD CONSTRAINT messages_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES public.registrars(id); @@ -4759,3 +4759,7 @@ INSERT INTO schema_migrations (version) VALUES ('20180613030330'); INSERT INTO schema_migrations (version) VALUES ('20180613045614'); +INSERT INTO schema_migrations (version) VALUES ('20180823161237'); + +INSERT INTO schema_migrations (version) VALUES ('20180823163548'); + diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 6b282d651..1c00a9a4d 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -251,10 +251,10 @@ RSpec.describe Domain do @domain.statuses = DomainStatus::OK # restore end - it 'should add poll message to registrar' do + it 'should notify registrar' do domain = create(:domain, name: 'testpollmessage123.ee') - domain.poll_message!(:poll_pending_update_confirmed_by_registrant) - domain.registrar.messages.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee' + domain.notify_registrar(:poll_pending_update_confirmed_by_registrant) + domain.registrar.notifications.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee' end context 'about registrant update confirm' do diff --git a/test/fixtures/messages.yml b/test/fixtures/notifications.yml similarity index 100% rename from test/fixtures/messages.yml rename to test/fixtures/notifications.yml diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb index d439a64e5..12c8351f6 100644 --- a/test/integration/api/domain_transfers_test.rb +++ b/test/integration/api/domain_transfers_test.rb @@ -47,7 +47,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest def test_notifies_old_registrar @old_registrar = @domain.registrar - assert_difference -> { @old_registrar.messages.count } do + assert_difference -> { @old_registrar.notifications.count } do post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } end end diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 6335fb27e..d399b6753 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -43,7 +43,7 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest def test_notifies_old_registrar @old_registrar = @domain.registrar - assert_difference -> { @old_registrar.messages.count } do + assert_difference -> { @old_registrar.notifications.count } do post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' } end end diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 2cf5c4254..71d74d622 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -2,8 +2,8 @@ require 'test_helper' class EppPollTest < ApplicationIntegrationTest # Deliberately does not conform to RFC5730, which requires the first message to be returned - def test_return_latest_message_when_queue_is_not_empty - message = messages(:domain_deleted) + def test_return_latest_notification_when_queue_is_not_empty + notification = notifications(:domain_deleted) request_xml = <<-XML @@ -20,13 +20,13 @@ class EppPollTest < ApplicationIntegrationTest assert_equal 1301.to_s, response_xml.at_css('result')[:code] assert_equal 1, response_xml.css('result').size assert_equal 2.to_s, response_xml.at_css('msgQ')[:count] - assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id] + assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id] assert_equal Time.zone.parse('2010-07-05').iso8601, response_xml.at_css('msgQ qDate').text assert_equal 'Your domain has been deleted', response_xml.at_css('msgQ msg').text end - def test_no_messages_in_queue - registrars(:bestnames).messages.delete_all(:delete_all) + def test_no_notifications + registrars(:bestnames).notifications.delete_all(:delete_all) request_xml = <<-XML @@ -44,49 +44,49 @@ class EppPollTest < ApplicationIntegrationTest assert_equal 1, response_xml.css('result').size end - def test_dequeue_message - message = messages(:greeting) + def test_dequeue_notification + notification = notifications(:greeting) request_xml = <<-XML - + XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - message.reload + notification.reload response_xml = Nokogiri::XML(response.body) - assert_not message.queued? + assert_not notification.queued? assert_equal 1000.to_s, response_xml.at_css('result')[:code] assert_equal 1, response_xml.css('result').size assert_equal 1.to_s, response_xml.at_css('msgQ')[:count] - assert_equal message.id.to_s, response_xml.at_css('msgQ')[:id] + assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id] end - def test_message_of_other_registrars_cannot_be_dequeued - message = messages(:farewell) + def test_notification_of_other_registrars_cannot_be_dequeued + notification = notifications(:farewell) request_xml = <<-XML - + XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' response_xml = Nokogiri::XML(response.body) - message.reload + notification.reload - assert message.queued? + assert notification.queued? assert_equal 2303.to_s, response_xml.at_css('result')[:code] end - def test_message_not_found + def test_notification_not_found request_xml = <<-XML diff --git a/test/jobs/domain_delete_confirm_job_test.rb b/test/jobs/domain_delete_confirm_job_test.rb index 9127ca628..fcd956213 100644 --- a/test/jobs/domain_delete_confirm_job_test.rb +++ b/test/jobs/domain_delete_confirm_job_test.rb @@ -18,19 +18,19 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase super end - def test_rejected_registrant_verification_polls_a_message + def test_rejected_registrant_verification_notifies_registrar DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) - last_registrar_message = @domain.registrar.messages.last - assert_equal(last_registrar_message.attached_obj_id, @domain.id) - assert_equal(last_registrar_message.body, 'Registrant rejected domain deletion: shop.test') + last_registrar_notification = @domain.registrar.notifications.last + assert_equal(last_registrar_notification.attached_obj_id, @domain.id) + assert_equal(last_registrar_notification.body, 'Registrant rejected domain deletion: shop.test') end - def test_accepted_registrant_verification_polls_a_message + def test_accepted_registrant_verification_notifies_registrar DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) - last_registrar_message = @domain.registrar.messages.last - assert_equal(last_registrar_message.attached_obj_id, @domain.id) - assert_equal(last_registrar_message.body, 'Registrant confirmed domain deletion: shop.test') + last_registrar_notification = @domain.registrar.notifications.last + assert_equal(last_registrar_notification.attached_obj_id, @domain.id) + assert_equal(last_registrar_notification.body, 'Registrant confirmed domain deletion: shop.test') end end diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index c507e2c98..fdbf0feb4 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -18,19 +18,19 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase super end - def test_rejected_registrant_verification_polls_a_message + def test_rejected_registrant_verification_notifies_registrar DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED) - last_registrar_message = @domain.registrar.messages.last - assert_equal(last_registrar_message.attached_obj_id, @domain.id) - assert_equal(last_registrar_message.body, 'Registrant rejected domain update: shop.test') + last_registrar_notification = @domain.registrar.notifications.last + assert_equal(last_registrar_notification.attached_obj_id, @domain.id) + assert_equal(last_registrar_notification.body, 'Registrant rejected domain update: shop.test') end - def test_accepted_registrant_verification_polls_a_message + def test_accepted_registrant_verification_notifies_registrar DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED) - last_registrar_message = @domain.registrar.messages.last - assert_equal(last_registrar_message.attached_obj_id, @domain.id) - assert_equal(last_registrar_message.body, 'Registrant confirmed domain update: shop.test') + last_registrar_notification = @domain.registrar.notifications.last + assert_equal(last_registrar_notification.attached_obj_id, @domain.id) + assert_equal(last_registrar_notification.body, 'Registrant confirmed domain update: shop.test') end end diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index 8c7494571..16c8fa6d8 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -14,7 +14,7 @@ class DomainTransferTest < ActiveSupport::TestCase def test_notifies_old_registrar_on_approval old_registrar = @domain_transfer.old_registrar - assert_difference -> { old_registrar.messages.count } do + assert_difference -> { old_registrar.notifications.count } do @domain_transfer.approve end @@ -24,9 +24,9 @@ class DomainTransferTest < ActiveSupport::TestCase id = @domain_transfer.id class_name = @domain_transfer.class.name - message = old_registrar.messages.last - assert_equal body, message.body - assert_equal id, message.attached_obj_id - assert_equal class_name, message.attached_obj_type + notification = old_registrar.notifications.last + assert_equal body, notification.body + assert_equal id, notification.attached_obj_id + assert_equal class_name, notification.attached_obj_type end end diff --git a/test/models/message_test.rb b/test/models/message_test.rb deleted file mode 100644 index ba2203d8a..000000000 --- a/test/models/message_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'test_helper' - -class MessageTest < ActiveSupport::TestCase - setup do - @message = messages(:greeting) - end - - def test_valid - assert @message.valid? - end - - def test_invalid_without_body - @message.body = nil - assert @message.invalid? - end - - def test_invalid_without_registrar - @message.registrar = nil - assert @message.invalid? - end - - def test_dequeue - @message.dequeue - @message.reload - assert_not @message.queued? - end -end \ No newline at end of file diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb new file mode 100644 index 000000000..cd85532f0 --- /dev/null +++ b/test/models/notification_test.rb @@ -0,0 +1,27 @@ +require 'test_helper' + +class NotificationTest < ActiveSupport::TestCase + setup do + @notification = notifications(:greeting) + end + + def test_valid + assert @notification.valid? + end + + def test_invalid_without_body + @notification.body = nil + assert @notification.invalid? + end + + def test_invalid_without_registrar + @notification.registrar = nil + assert @notification.invalid? + end + + def test_dequeue + @notification.dequeue + @notification.reload + assert_not @notification.queued? + end +end \ No newline at end of file diff --git a/test/system/admin_area/domains/force_delete_test.rb b/test/system/admin_area/domains/force_delete_test.rb index 22bb23d38..525e2de4c 100644 --- a/test/system/admin_area/domains/force_delete_test.rb +++ b/test/system/admin_area/domains/force_delete_test.rb @@ -22,7 +22,7 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase end def test_notifies_registrar - assert_difference '@domain.registrar.messages.size' do + assert_difference '@domain.registrar.notifications.size' do visit edit_admin_domain_url(@domain) click_link_or_button 'Force delete domain' end From dfff6f6d12ae860a3fd4960ea6446e0953059f66 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 23 Aug 2018 21:26:33 +0300 Subject: [PATCH 10/37] Rename `notifications.body` to `text` --- app/controllers/admin/domains/force_delete_controller.rb | 2 +- app/jobs/domain_delete_job.rb | 2 +- app/models/domain.rb | 2 +- app/models/domain_transfer.rb | 2 +- app/models/epp/domain.rb | 4 ++-- app/models/notification.rb | 2 +- app/views/epp/poll/poll_keyrelay.xml.builder | 2 +- app/views/epp/poll/poll_req.xml.builder | 2 +- .../20180823174331_rename_notifications_body_to_text.rb | 5 +++++ db/structure.sql | 4 +++- spec/models/domain_spec.rb | 3 ++- test/fixtures/notifications.yml | 6 +++--- test/jobs/domain_delete_confirm_job_test.rb | 4 ++-- test/jobs/domain_update_confirm_job_test.rb | 4 ++-- test/models/domain_transfer_test.rb | 4 ++-- test/models/notification_test.rb | 4 ++-- 16 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20180823174331_rename_notifications_body_to_text.rb diff --git a/app/controllers/admin/domains/force_delete_controller.rb b/app/controllers/admin/domains/force_delete_controller.rb index 155b4fa41..946231077 100644 --- a/app/controllers/admin/domains/force_delete_controller.rb +++ b/app/controllers/admin/domains/force_delete_controller.rb @@ -6,7 +6,7 @@ module Admin domain.transaction do domain.schedule_force_delete - domain.registrar.notifications.create!(body: t('force_delete_set_on_domain', + domain.registrar.notifications.create!(text: t('force_delete_set_on_domain', domain_name: domain.name)) if notify_by_email? diff --git a/app/jobs/domain_delete_job.rb b/app/jobs/domain_delete_job.rb index 15195b588..b45f96713 100644 --- a/app/jobs/domain_delete_job.rb +++ b/app/jobs/domain_delete_job.rb @@ -9,7 +9,7 @@ class DomainDeleteJob < Que::Job domain.destroy bye_bye = domain.versions.last domain.registrar.notifications.create!( - body: "#{I18n.t(:domain_deleted)}: #{domain.name}", + text: "#{I18n.t(:domain_deleted)}: #{domain.name}", attached_obj_id: bye_bye.id, attached_obj_type: bye_bye.class.to_s ) diff --git a/app/models/domain.rb b/app/models/domain.rb index d39e86272..84ecc37d0 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -272,7 +272,7 @@ class Domain < ActiveRecord::Base def notify_registrar(message_key) registrar.notifications.create!( - body: "#{I18n.t(message_key)}: #{name}", + text: "#{I18n.t(message_key)}: #{name}", attached_obj_id: id, attached_obj_type: self.class.to_s ) diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 2ac35a0db..91cdb2d67 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -74,7 +74,7 @@ class DomainTransfer < ActiveRecord::Base old_registrant_code = domain.registrant.code old_registrar.notifications.create!( - body: I18n.t('notifications.texts.domain_transfer', + text: I18n.t('notifications.texts.domain_transfer', domain_name: domain.name, old_contacts_codes: old_contacts_codes, old_registrant_code: old_registrant_code), diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 2bfd10215..2f25f3da5 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -626,7 +626,7 @@ class Epp::Domain < Domain if dt.pending? registrar.notifications.create!( - body: I18n.t('transfer_requested'), + text: I18n.t('transfer_requested'), attached_obj_id: dt.id, attached_obj_type: dt.class.to_s ) @@ -728,7 +728,7 @@ class Epp::Domain < Domain return false unless valid? registrar.notifications.create!( - body: 'Key Relay action completed successfully.', + text: 'Key Relay action completed successfully.', attached_obj_type: kr.class.to_s, attached_obj_id: kr.id ) diff --git a/app/models/notification.rb b/app/models/notification.rb index 09f9377da..5fbdeccb5 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -6,7 +6,7 @@ class Notification < ActiveRecord::Base scope :queued, -> { where(queued: true) } - validates :body, presence: true + validates :text, presence: true def dequeue self.queued = false diff --git a/app/views/epp/poll/poll_keyrelay.xml.builder b/app/views/epp/poll/poll_keyrelay.xml.builder index c79b2a574..606f03936 100644 --- a/app/views/epp/poll/poll_keyrelay.xml.builder +++ b/app/views/epp/poll/poll_keyrelay.xml.builder @@ -12,7 +12,7 @@ xml.epp( xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do xml.qDate @notification.created_at.try(:iso8601) - xml.msg @notification.body + xml.msg @notification.text end xml.resData do diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index f483e017b..3eb78f7a1 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -6,7 +6,7 @@ xml.epp_head do xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do xml.qDate @notification.created_at.try(:iso8601) - xml.msg @notification.body + xml.msg @notification.text end if @notification.attached_obj_type == 'DomainTransfer' diff --git a/db/migrate/20180823174331_rename_notifications_body_to_text.rb b/db/migrate/20180823174331_rename_notifications_body_to_text.rb new file mode 100644 index 000000000..d0b5e0514 --- /dev/null +++ b/db/migrate/20180823174331_rename_notifications_body_to_text.rb @@ -0,0 +1,5 @@ +class RenameNotificationsBodyToText < ActiveRecord::Migration + def change + rename_column :notifications, :body, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index d1f6adb36..355b5ef63 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1999,7 +1999,7 @@ ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id; CREATE TABLE public.notifications ( id integer NOT NULL, registrar_id integer NOT NULL, - body character varying NOT NULL, + text character varying NOT NULL, attached_obj_type character varying, attached_obj_id integer, queued boolean, @@ -4763,3 +4763,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180823161237'); INSERT INTO schema_migrations (version) VALUES ('20180823163548'); +INSERT INTO schema_migrations (version) VALUES ('20180823174331'); + diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 1c00a9a4d..858570c68 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -252,9 +252,10 @@ RSpec.describe Domain do end it 'should notify registrar' do + text = 'Registrant confirmed domain update: testpollmessage123.ee' domain = create(:domain, name: 'testpollmessage123.ee') domain.notify_registrar(:poll_pending_update_confirmed_by_registrant) - domain.registrar.notifications.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee' + domain.registrar.notifications.first.text.should == text end context 'about registrant update confirm' do diff --git a/test/fixtures/notifications.yml b/test/fixtures/notifications.yml index 58ae3bd6d..aaa601a61 100644 --- a/test/fixtures/notifications.yml +++ b/test/fixtures/notifications.yml @@ -1,15 +1,15 @@ greeting: - body: Welcome! + text: Welcome! queued: true registrar: bestnames domain_deleted: - body: Your domain has been deleted + text: Your domain has been deleted queued: true registrar: bestnames created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %> farewell: - body: Good bye! + text: Good bye! queued: true registrar: goodnames \ No newline at end of file diff --git a/test/jobs/domain_delete_confirm_job_test.rb b/test/jobs/domain_delete_confirm_job_test.rb index fcd956213..51af58c24 100644 --- a/test/jobs/domain_delete_confirm_job_test.rb +++ b/test/jobs/domain_delete_confirm_job_test.rb @@ -23,7 +23,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase last_registrar_notification = @domain.registrar.notifications.last assert_equal(last_registrar_notification.attached_obj_id, @domain.id) - assert_equal(last_registrar_notification.body, 'Registrant rejected domain deletion: shop.test') + assert_equal(last_registrar_notification.text, 'Registrant rejected domain deletion: shop.test') end def test_accepted_registrant_verification_notifies_registrar @@ -31,6 +31,6 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase last_registrar_notification = @domain.registrar.notifications.last assert_equal(last_registrar_notification.attached_obj_id, @domain.id) - assert_equal(last_registrar_notification.body, 'Registrant confirmed domain deletion: shop.test') + assert_equal(last_registrar_notification.text, 'Registrant confirmed domain deletion: shop.test') end end diff --git a/test/jobs/domain_update_confirm_job_test.rb b/test/jobs/domain_update_confirm_job_test.rb index fdbf0feb4..070b5d5f7 100644 --- a/test/jobs/domain_update_confirm_job_test.rb +++ b/test/jobs/domain_update_confirm_job_test.rb @@ -23,7 +23,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase last_registrar_notification = @domain.registrar.notifications.last assert_equal(last_registrar_notification.attached_obj_id, @domain.id) - assert_equal(last_registrar_notification.body, 'Registrant rejected domain update: shop.test') + assert_equal(last_registrar_notification.text, 'Registrant rejected domain update: shop.test') end def test_accepted_registrant_verification_notifies_registrar @@ -31,6 +31,6 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase last_registrar_notification = @domain.registrar.notifications.last assert_equal(last_registrar_notification.attached_obj_id, @domain.id) - assert_equal(last_registrar_notification.body, 'Registrant confirmed domain update: shop.test') + assert_equal(last_registrar_notification.text, 'Registrant confirmed domain update: shop.test') end end diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index 16c8fa6d8..943fc2a0a 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -18,14 +18,14 @@ class DomainTransferTest < ActiveSupport::TestCase @domain_transfer.approve end - body = 'Transfer of domain shop.test has been approved.' \ + text = 'Transfer of domain shop.test has been approved.' \ ' It was associated with registrant john-001' \ ' and contacts acme-ltd-001, jane-001, william-001.' id = @domain_transfer.id class_name = @domain_transfer.class.name notification = old_registrar.notifications.last - assert_equal body, notification.body + assert_equal text, notification.text assert_equal id, notification.attached_obj_id assert_equal class_name, notification.attached_obj_type end diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index cd85532f0..c9ee91a8e 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -9,8 +9,8 @@ class NotificationTest < ActiveSupport::TestCase assert @notification.valid? end - def test_invalid_without_body - @notification.body = nil + def test_invalid_without_text + @notification.text = '' assert @notification.invalid? end From 7a9a7c052f17530527ccf284fe88ae14a1f6b0ed Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 00:36:58 +0300 Subject: [PATCH 11/37] Rename `notifications.queued` to `read` --- app/controllers/epp/polls_controller.rb | 6 +++--- app/models/api_user.rb | 4 ++-- app/models/notification.rb | 8 ++++---- app/views/epp/poll/poll_ack.xml.builder | 2 +- app/views/epp/poll/poll_keyrelay.xml.builder | 2 +- app/views/epp/poll/poll_req.xml.builder | 2 +- .../20180823212823_rename_notifications_queued_to_read.rb | 5 +++++ db/structure.sql | 4 +++- test/fixtures/notifications.yml | 6 +++--- test/integration/epp/poll_test.rb | 8 ++++---- test/models/notification_test.rb | 6 +++--- 11 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 db/migrate/20180823212823_rename_notifications_queued_to_read.rb diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb index ef41bfaf7..0ce1ff5c7 100644 --- a/app/controllers/epp/polls_controller.rb +++ b/app/controllers/epp/polls_controller.rb @@ -9,7 +9,7 @@ class Epp::PollsController < EppController private def req_poll - @notification = current_user.queued_notifications.last + @notification = current_user.unread_notifications.last render_epp_response 'epp/poll/poll_no_messages' and return unless @notification if @notification.attached_obj_type && @notification.attached_obj_id @@ -36,7 +36,7 @@ class Epp::PollsController < EppController end def ack_poll - @notification = current_user.queued_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID']) + @notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID']) unless @notification epp_errors << { @@ -47,7 +47,7 @@ class Epp::PollsController < EppController handle_errors and return end - handle_errors(@notification) and return unless @notification.dequeue + handle_errors(@notification) and return unless @notification.mark_as_read render_epp_response 'epp/poll/poll_ack' end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index 8d5018568..850e92730 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -79,8 +79,8 @@ class ApiUser < User username end - def queued_notifications - registrar.notifications.queued + def unread_notifications + registrar.notifications.unread end def registrar_pki_ok?(crt, cn) diff --git a/app/models/notification.rb b/app/models/notification.rb index 5fbdeccb5..1819e86dc 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -2,14 +2,14 @@ class Notification < ActiveRecord::Base include Versions # version/notification_version.rb belongs_to :registrar, required: true - before_create -> { self.queued = true } + before_create -> { self.read = false } - scope :queued, -> { where(queued: true) } + scope :unread, -> { where(read: false) } validates :text, presence: true - def dequeue - self.queued = false + def mark_as_read + self.read = true save end diff --git a/app/views/epp/poll/poll_ack.xml.builder b/app/views/epp/poll/poll_ack.xml.builder index 1ee6fa315..835f13b86 100644 --- a/app/views/epp/poll/poll_ack.xml.builder +++ b/app/views/epp/poll/poll_ack.xml.builder @@ -4,7 +4,7 @@ xml.epp_head do xml.msg 'Command completed successfully' end - xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) + xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) render('epp/shared/trID', builder: xml) end diff --git a/app/views/epp/poll/poll_keyrelay.xml.builder b/app/views/epp/poll/poll_keyrelay.xml.builder index 606f03936..c5415273a 100644 --- a/app/views/epp/poll/poll_keyrelay.xml.builder +++ b/app/views/epp/poll/poll_keyrelay.xml.builder @@ -10,7 +10,7 @@ xml.epp( xml.msg 'Command completed successfully; ack to dequeue' end - xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do + xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) do xml.qDate @notification.created_at.try(:iso8601) xml.msg @notification.text end diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index 3eb78f7a1..6a3893c69 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -4,7 +4,7 @@ xml.epp_head do xml.msg 'Command completed successfully; ack to dequeue' end - xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do + xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) do xml.qDate @notification.created_at.try(:iso8601) xml.msg @notification.text end diff --git a/db/migrate/20180823212823_rename_notifications_queued_to_read.rb b/db/migrate/20180823212823_rename_notifications_queued_to_read.rb new file mode 100644 index 000000000..e0cc8f7bd --- /dev/null +++ b/db/migrate/20180823212823_rename_notifications_queued_to_read.rb @@ -0,0 +1,5 @@ +class RenameNotificationsQueuedToRead < ActiveRecord::Migration + def change + rename_column :notifications, :queued, :read + end +end diff --git a/db/structure.sql b/db/structure.sql index 355b5ef63..cc4f2e29c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2002,7 +2002,7 @@ CREATE TABLE public.notifications ( text character varying NOT NULL, attached_obj_type character varying, attached_obj_id integer, - queued boolean, + read boolean, created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, @@ -4765,3 +4765,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180823163548'); INSERT INTO schema_migrations (version) VALUES ('20180823174331'); +INSERT INTO schema_migrations (version) VALUES ('20180823212823'); + diff --git a/test/fixtures/notifications.yml b/test/fixtures/notifications.yml index aaa601a61..37a69d443 100644 --- a/test/fixtures/notifications.yml +++ b/test/fixtures/notifications.yml @@ -1,15 +1,15 @@ greeting: text: Welcome! - queued: true + read: false registrar: bestnames domain_deleted: text: Your domain has been deleted - queued: true + read: false registrar: bestnames created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %> farewell: text: Good bye! - queued: true + read: false registrar: goodnames \ No newline at end of file diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 71d74d622..30f7a2891 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -44,7 +44,7 @@ class EppPollTest < ApplicationIntegrationTest assert_equal 1, response_xml.css('result').size end - def test_dequeue_notification + def test_mark_as_read notification = notifications(:greeting) request_xml = <<-XML @@ -60,14 +60,14 @@ class EppPollTest < ApplicationIntegrationTest notification.reload response_xml = Nokogiri::XML(response.body) - assert_not notification.queued? + assert notification.read? assert_equal 1000.to_s, response_xml.at_css('result')[:code] assert_equal 1, response_xml.css('result').size assert_equal 1.to_s, response_xml.at_css('msgQ')[:count] assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id] end - def test_notification_of_other_registrars_cannot_be_dequeued + def test_notification_of_other_registrars_cannot_be_marked_as_read notification = notifications(:farewell) request_xml = <<-XML @@ -82,7 +82,7 @@ class EppPollTest < ApplicationIntegrationTest response_xml = Nokogiri::XML(response.body) notification.reload - assert notification.queued? + assert_not notification.read? assert_equal 2303.to_s, response_xml.at_css('result')[:code] end diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index c9ee91a8e..da8f3bdec 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -19,9 +19,9 @@ class NotificationTest < ActiveSupport::TestCase assert @notification.invalid? end - def test_dequeue - @notification.dequeue + def test_mark_as_read + @notification.mark_as_read @notification.reload - assert_not @notification.queued? + assert @notification.read? end end \ No newline at end of file From 757ac8f10a6d5646a98fc882d78d5bfa07a58ab5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 10:29:53 +0300 Subject: [PATCH 12/37] Add clarification --- app/models/notification.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/notification.rb b/app/models/notification.rb index 1819e86dc..fe50cadea 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -13,6 +13,7 @@ class Notification < ActiveRecord::Base save end + # Needed for EPP log def name "-" end From 7ccd662d608a911445bfd4e1a703b1ad7173e1de Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 11:09:26 +0300 Subject: [PATCH 13/37] Do not halt in before_create --- app/models/notification.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index fe50cadea..df2dc1a9c 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -2,7 +2,7 @@ class Notification < ActiveRecord::Base include Versions # version/notification_version.rb belongs_to :registrar, required: true - before_create -> { self.read = false } + before_create -> { self.read = false; true } scope :unread, -> { where(read: false) } From cc0a6c229fefadc7ff7230cc63e010fb3e1bb251 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 13:33:39 +0300 Subject: [PATCH 14/37] Eliminate three-state boolean --- .../20180824102834_change_notifications_read_to_not_null.rb | 5 +++++ db/structure.sql | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180824102834_change_notifications_read_to_not_null.rb diff --git a/db/migrate/20180824102834_change_notifications_read_to_not_null.rb b/db/migrate/20180824102834_change_notifications_read_to_not_null.rb new file mode 100644 index 000000000..916a32b28 --- /dev/null +++ b/db/migrate/20180824102834_change_notifications_read_to_not_null.rb @@ -0,0 +1,5 @@ +class ChangeNotificationsReadToNotNull < ActiveRecord::Migration + def change + change_column_null :notifications, :read, false + end +end diff --git a/db/structure.sql b/db/structure.sql index cc4f2e29c..cc1019f47 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2002,7 +2002,7 @@ CREATE TABLE public.notifications ( text character varying NOT NULL, attached_obj_type character varying, attached_obj_id integer, - read boolean, + read boolean NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, @@ -4767,3 +4767,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180823174331'); INSERT INTO schema_migrations (version) VALUES ('20180823212823'); +INSERT INTO schema_migrations (version) VALUES ('20180824102834'); + From 9d74cd56730c36a343a955f83c095a9c3d235bf7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 14:10:16 +0300 Subject: [PATCH 15/37] Add tests --- app/models/notification.rb | 10 ++++++++-- test/models/notification_test.rb | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index df2dc1a9c..c8b46c17e 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -2,12 +2,12 @@ class Notification < ActiveRecord::Base include Versions # version/notification_version.rb belongs_to :registrar, required: true - before_create -> { self.read = false; true } - scope :unread, -> { where(read: false) } validates :text, presence: true + after_initialize :set_defaults + def mark_as_read self.read = true save @@ -17,4 +17,10 @@ class Notification < ActiveRecord::Base def name "-" end + + private + + def set_defaults + self.read = false if read.nil? + end end diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index da8f3bdec..96379d77f 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -19,6 +19,19 @@ class NotificationTest < ActiveSupport::TestCase assert @notification.invalid? end + def test_unread_by_default + notification = Notification.new(registrar: registrars(:bestnames), text: 'test') + assert_not notification.read? + + notification.save! + assert_not notification.read? + end + + def test_honor_given_read_state + notification = Notification.new(read: true) + assert notification.read? + end + def test_mark_as_read @notification.mark_as_read @notification.reload From a1fb0e2e6122e7f1bb0616dc0449d40dde4bb318 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 14:14:29 +0300 Subject: [PATCH 16/37] Introduce negative predicate --- app/models/notification.rb | 4 ++++ test/integration/epp/poll_test.rb | 2 +- test/models/notification_test.rb | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index c8b46c17e..b0b373978 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -13,6 +13,10 @@ class Notification < ActiveRecord::Base save end + def unread? + !read? + end + # Needed for EPP log def name "-" diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index 30f7a2891..e04874ca8 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -82,7 +82,7 @@ class EppPollTest < ApplicationIntegrationTest response_xml = Nokogiri::XML(response.body) notification.reload - assert_not notification.read? + assert notification.unread? assert_equal 2303.to_s, response_xml.at_css('result')[:code] end diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index 96379d77f..e6783efcf 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -21,10 +21,10 @@ class NotificationTest < ActiveSupport::TestCase def test_unread_by_default notification = Notification.new(registrar: registrars(:bestnames), text: 'test') - assert_not notification.read? + assert notification.unread? notification.save! - assert_not notification.read? + assert notification.unread? end def test_honor_given_read_state From 1183d06c09fa7ba5c349add336a7373e1e27235e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 14:18:40 +0300 Subject: [PATCH 17/37] Remove app-level association validation --- app/models/notification.rb | 2 +- test/models/notification_test.rb | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index b0b373978..1e9dfa3dd 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,6 +1,6 @@ class Notification < ActiveRecord::Base include Versions # version/notification_version.rb - belongs_to :registrar, required: true + belongs_to :registrar scope :unread, -> { where(read: false) } diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index e6783efcf..bfd577fb9 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -14,11 +14,6 @@ class NotificationTest < ActiveSupport::TestCase assert @notification.invalid? end - def test_invalid_without_registrar - @notification.registrar = nil - assert @notification.invalid? - end - def test_unread_by_default notification = Notification.new(registrar: registrars(:bestnames), text: 'test') assert notification.unread? From 412641cdb093f9e2476da9dede938d11a9a1d9eb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 24 Aug 2018 14:34:44 +0300 Subject: [PATCH 18/37] Disallow marking a notification as read again --- app/models/notification.rb | 1 + test/models/notification_test.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/models/notification.rb b/app/models/notification.rb index 1e9dfa3dd..0b1829267 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -9,6 +9,7 @@ class Notification < ActiveRecord::Base after_initialize :set_defaults def mark_as_read + raise 'Read notification cannot be marked as read again' if read? self.read = true save end diff --git a/test/models/notification_test.rb b/test/models/notification_test.rb index bfd577fb9..3db685e0c 100644 --- a/test/models/notification_test.rb +++ b/test/models/notification_test.rb @@ -32,4 +32,11 @@ class NotificationTest < ActiveSupport::TestCase @notification.reload assert @notification.read? end + + def test_read_notification_cannot_be_marked_as_read_again + @notification.mark_as_read + assert_raises do + @notification.mark_as_read + end + end end \ No newline at end of file From 00167a781d65d949709431dad89f51b7da65dfd3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 25 Aug 2018 21:34:52 +0300 Subject: [PATCH 19/37] Add notification text tag --- db/migrate/20180825153657_add_text_tag_to_notifications.rb | 5 +++++ db/structure.sql | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180825153657_add_text_tag_to_notifications.rb diff --git a/db/migrate/20180825153657_add_text_tag_to_notifications.rb b/db/migrate/20180825153657_add_text_tag_to_notifications.rb new file mode 100644 index 000000000..4e528468b --- /dev/null +++ b/db/migrate/20180825153657_add_text_tag_to_notifications.rb @@ -0,0 +1,5 @@ +class AddTextTagToNotifications < ActiveRecord::Migration + def change + add_column :notifications, :text_tag, :string + end +end diff --git a/db/structure.sql b/db/structure.sql index cc1019f47..5fea474e6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2006,7 +2006,8 @@ CREATE TABLE public.notifications ( created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, - updator_str character varying + updator_str character varying, + text_tag character varying ); @@ -4769,3 +4770,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180823212823'); INSERT INTO schema_migrations (version) VALUES ('20180824102834'); +INSERT INTO schema_migrations (version) VALUES ('20180825153657'); + From 4a8c39e33fe8a3a3ed959005c87ce0bb83dcb679 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 26 Aug 2018 22:36:07 +0300 Subject: [PATCH 20/37] Improve readability --- test/integration/epp/poll_test.rb | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index e04874ca8..e309c4a7e 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -15,14 +15,14 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - response_xml = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) - assert_equal 1301.to_s, response_xml.at_css('result')[:code] - assert_equal 1, response_xml.css('result').size - assert_equal 2.to_s, response_xml.at_css('msgQ')[:count] - assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id] - assert_equal Time.zone.parse('2010-07-05').iso8601, response_xml.at_css('msgQ qDate').text - assert_equal 'Your domain has been deleted', response_xml.at_css('msgQ msg').text + assert_equal 1301.to_s, xml_doc.at_css('result')[:code] + assert_equal 1, xml_doc.css('result').size + assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count] + assert_equal notification.id.to_s, xml_doc.at_css('msgQ')[:id] + assert_equal Time.zone.parse('2010-07-05').iso8601, xml_doc.at_css('msgQ qDate').text + assert_equal 'Your domain has been deleted', xml_doc.at_css('msgQ msg').text end def test_no_notifications @@ -38,10 +38,10 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - response_xml = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) - assert_equal 1300.to_s, response_xml.at_css('result')[:code] - assert_equal 1, response_xml.css('result').size + assert_equal 1300.to_s, xml_doc.at_css('result')[:code] + assert_equal 1, xml_doc.css('result').size end def test_mark_as_read @@ -58,13 +58,13 @@ class EppPollTest < ApplicationIntegrationTest post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' notification.reload - response_xml = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) assert notification.read? - assert_equal 1000.to_s, response_xml.at_css('result')[:code] - assert_equal 1, response_xml.css('result').size - assert_equal 1.to_s, response_xml.at_css('msgQ')[:count] - assert_equal notification.id.to_s, response_xml.at_css('msgQ')[:id] + assert_equal 1000.to_s, xml_doc.at_css('result')[:code] + assert_equal 1, xml_doc.css('result').size + assert_equal 1.to_s, xml_doc.at_css('msgQ')[:count] + assert_equal notification.id.to_s, xml_doc.at_css('msgQ')[:id] end def test_notification_of_other_registrars_cannot_be_marked_as_read @@ -79,11 +79,11 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - response_xml = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) notification.reload assert notification.unread? - assert_equal 2303.to_s, response_xml.at_css('result')[:code] + assert_equal 2303.to_s, xml_doc.at_css('result')[:code] end def test_notification_not_found @@ -96,8 +96,8 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - response_xml = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) - assert_equal 2303.to_s, response_xml.at_css('result')[:code] + assert_equal 2303.to_s, xml_doc.at_css('result')[:code] end end \ No newline at end of file From 4ac992f6194a02de39250fcb49eb84d1a9dc5af7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 26 Aug 2018 22:37:45 +0300 Subject: [PATCH 21/37] Reformat --- test/integration/epp/poll_test.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb index e309c4a7e..a824d4e57 100644 --- a/test/integration/epp/poll_test.rb +++ b/test/integration/epp/poll_test.rb @@ -5,8 +5,7 @@ class EppPollTest < ApplicationIntegrationTest def test_return_latest_notification_when_queue_is_not_empty notification = notifications(:domain_deleted) - request_xml = - <<-XML + request_xml = <<-XML @@ -15,8 +14,8 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - xml_doc = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) assert_equal 1301.to_s, xml_doc.at_css('result')[:code] assert_equal 1, xml_doc.css('result').size assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count] @@ -28,8 +27,7 @@ class EppPollTest < ApplicationIntegrationTest def test_no_notifications registrars(:bestnames).notifications.delete_all(:delete_all) - request_xml = - <<-XML + request_xml = <<-XML @@ -38,8 +36,8 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - xml_doc = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) assert_equal 1300.to_s, xml_doc.at_css('result')[:code] assert_equal 1, xml_doc.css('result').size end @@ -58,8 +56,8 @@ class EppPollTest < ApplicationIntegrationTest post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' notification.reload - xml_doc = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) assert notification.read? assert_equal 1000.to_s, xml_doc.at_css('result')[:code] assert_equal 1, xml_doc.css('result').size @@ -79,9 +77,9 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - xml_doc = Nokogiri::XML(response.body) notification.reload + xml_doc = Nokogiri::XML(response.body) assert notification.unread? assert_equal 2303.to_s, xml_doc.at_css('result')[:code] end @@ -96,8 +94,8 @@ class EppPollTest < ApplicationIntegrationTest XML post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames' - xml_doc = Nokogiri::XML(response.body) + xml_doc = Nokogiri::XML(response.body) assert_equal 2303.to_s, xml_doc.at_css('result')[:code] end end \ No newline at end of file From 034e8e9d117156402ae099eded7d175a0e27a7d2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 27 Aug 2018 12:27:45 +0300 Subject: [PATCH 22/37] 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 69027abc9fe3b89730c2d4b8199f62f28b01b21c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 27 Aug 2018 16:39:14 +0300 Subject: [PATCH 23/37] Remove unused view --- app/views/epp/domains/partials/_delete_complete.xml.builder | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 app/views/epp/domains/partials/_delete_complete.xml.builder diff --git a/app/views/epp/domains/partials/_delete_complete.xml.builder b/app/views/epp/domains/partials/_delete_complete.xml.builder deleted file mode 100644 index 509ac6953..000000000 --- a/app/views/epp/domains/partials/_delete_complete.xml.builder +++ /dev/null @@ -1,4 +0,0 @@ -builder.tag!('domain:delData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do - builder.tag!('domain:name', bye_bye.object['name']) - builder.tag!('domain:exDate', bye_bye.created_at) -end From 5b625fa4407631ebea7f52247a6b5e64328cb46c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 29 Aug 2018 13:20:31 +0300 Subject: [PATCH 24/37] Update fixture --- test/fixtures/contacts.yml | 2 +- test/system/admin_area/contacts_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index cb9387090..62e3e0a30 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -24,7 +24,7 @@ william: &william street: Main Street zip: 12345 city: New York - state: New York + state: New York State country_code: US statuses: - ok diff --git a/test/system/admin_area/contacts_test.rb b/test/system/admin_area/contacts_test.rb index c72004988..7ace0b7ec 100644 --- a/test/system/admin_area/contacts_test.rb +++ b/test/system/admin_area/contacts_test.rb @@ -20,6 +20,6 @@ class AdminContactsTest < ApplicationSystemTestCase visit admin_contact_path(@contact) assert_text('Street Main Street City New York Postcode 12345 ' \ - 'State New York Country United States of America') + 'State New York State Country United States of America') end end From 16fd21f7cfa625ceffa6e16b3d407180ab0e9b16 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 2 Sep 2018 21:20:41 +0300 Subject: [PATCH 25/37] Revert "Add notification text tag" This reverts commit 00167a781d65d949709431dad89f51b7da65dfd3. --- db/migrate/20180825153657_add_text_tag_to_notifications.rb | 5 ----- db/structure.sql | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 db/migrate/20180825153657_add_text_tag_to_notifications.rb diff --git a/db/migrate/20180825153657_add_text_tag_to_notifications.rb b/db/migrate/20180825153657_add_text_tag_to_notifications.rb deleted file mode 100644 index 4e528468b..000000000 --- a/db/migrate/20180825153657_add_text_tag_to_notifications.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTextTagToNotifications < ActiveRecord::Migration - def change - add_column :notifications, :text_tag, :string - end -end diff --git a/db/structure.sql b/db/structure.sql index b93136de2..21d39236e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2007,8 +2007,7 @@ CREATE TABLE public.notifications ( created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, - updator_str character varying, - text_tag character varying + updator_str character varying ); @@ -4779,5 +4778,3 @@ INSERT INTO schema_migrations (version) VALUES ('20180824092855'); INSERT INTO schema_migrations (version) VALUES ('20180824102834'); -INSERT INTO schema_migrations (version) VALUES ('20180825153657'); - From dd519bd8d04f9aae9cc0a70398df1df11f62c624 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 2 Sep 2018 22:24:27 +0300 Subject: [PATCH 26/37] Update CodeClimate config --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 294b9335c..de5285aa5 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -19,6 +19,7 @@ plugins: enabled: true rubocop: enabled: true + channel: rubocop-0-58 exclude_patterns: - "bin/" - "config/" From 85c16334009a9974c310c6428eea097a31dfef89 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 4 Sep 2018 11:51:47 +0300 Subject: [PATCH 27/37] Fix a regression, where `user_session_timeout` setting in `application.yml` is not respected. Introduced in ebe831e78247bde3eb50347969b46622ee24db21 --- config/initializers/devise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index c2f89e691..56791c45d 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -173,7 +173,7 @@ Devise.setup do |config| # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. - # config.timeout_in = 30.minutes + config.timeout_in = ENV['user_session_timeout'].to_i.seconds if ENV['user_session_timeout'] # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. From de83755fc914c1a74c646e4f3bf0d054ed84ac6b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 6 Sep 2018 12:29:12 +0300 Subject: [PATCH 28/37] An addition to 840b6da1be52e9be93d6400396a2120bf3d51653 --- app/controllers/registrar/payments_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/registrar/payments_controller.rb b/app/controllers/registrar/payments_controller.rb index 57565b9c2..466f5a865 100644 --- a/app/controllers/registrar/payments_controller.rb +++ b/app/controllers/registrar/payments_controller.rb @@ -3,7 +3,8 @@ class Registrar protect_from_forgery except: [:back, :callback] skip_authorization_check # actually anyone can pay, no problems at all - skip_before_action :authenticate_user!, :check_ip_restriction, only: [:back, :callback] + skip_before_action :authenticate_registrar_user!, :check_ip_restriction, + only: [:back, :callback] before_action :check_supported_payment_method def pay From 0238aa7330b8401cbe033fdd575bd4e9ac51b38d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 16 Sep 2018 16:02:46 +0300 Subject: [PATCH 29/37] Remove duplicate require It is already present in `application.rb` --- app/models/account_activity.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb index b014ea5b8..c5857631e 100644 --- a/app/models/account_activity.rb +++ b/app/models/account_activity.rb @@ -1,5 +1,3 @@ -require 'csv' - class AccountActivity < ActiveRecord::Base include Versions belongs_to :account, required: true From 762833726ada76e8573d76d94b081885212873a3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 4 Sep 2018 13:39:26 +0300 Subject: [PATCH 30/37] Remove duplicate field --- app/views/admin/registrars/_contacts.html.erb | 3 --- test/fixtures/registrars.yml | 3 ++- test/system/admin_area/registrars/details_test.rb | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/admin/registrars/_contacts.html.erb b/app/views/admin/registrars/_contacts.html.erb index 190e48458..7599c68c3 100644 --- a/app/views/admin/registrars/_contacts.html.erb +++ b/app/views/admin/registrars/_contacts.html.erb @@ -16,9 +16,6 @@
<%= t(:contact_email) %>
<%= @registrar.email %>
- -
<%= Registrar.human_attribute_name :billing_email %>
-
<%= @registrar.billing_email %>
diff --git a/test/fixtures/registrars.yml b/test/fixtures/registrars.yml index 65400bf13..d3d6b1c20 100644 --- a/test/fixtures/registrars.yml +++ b/test/fixtures/registrars.yml @@ -40,4 +40,5 @@ complete: accounting_customer_code: US0001 language: en vat_no: US12345 - vat_rate: 0.05 \ No newline at end of file + vat_rate: 0.05 + billing_email: billing@bestnames.test \ No newline at end of file diff --git a/test/system/admin_area/registrars/details_test.rb b/test/system/admin_area/registrars/details_test.rb index 1dfb4b03a..c8eb27829 100644 --- a/test/system/admin_area/registrars/details_test.rb +++ b/test/system/admin_area/registrars/details_test.rb @@ -14,5 +14,6 @@ class AdminAreaRegistrarDetailsTest < ApplicationSystemTestCase assert_text 'VAT number US12345' assert_text 'VAT rate 5.0%' assert_text 'Language English' + assert_text 'billing@bestnames.test' end end From d9526c6f3a06b937ab3a86533f7345dd53258f20 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 18 Sep 2018 13:30:29 +0300 Subject: [PATCH 31/37] 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 32/37] 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 33/37] 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 From 3633d448223649db97a53e60b0a332648bd19cbd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 6 Sep 2018 00:32:58 +0300 Subject: [PATCH 34/37] Update `money-rails` gem --- Gemfile.lock | 22 ++++++------ config/initializers/money.rb | 69 ++---------------------------------- test/learning/money_test.rb | 8 +++++ 3 files changed, 21 insertions(+), 78 deletions(-) create mode 100644 test/learning/money_test.rb diff --git a/Gemfile.lock b/Gemfile.lock index 3285380f7..29ca2aa28 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -217,7 +217,8 @@ GEM httpi (2.4.2) rack socksify - i18n (0.8.6) + i18n (0.9.5) + concurrent-ruby (~> 1.0) i18n_data (0.7.0) ice_nine (0.11.2) isikukood (0.1.2) @@ -252,15 +253,14 @@ GEM mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.11.3) - monetize (1.6.0) - money (~> 6.8) - money (6.8.3) - i18n (>= 0.6.4, < 0.9) - sixarm_ruby_unaccent (>= 1.1.1, < 2) - money-rails (1.8.0) + monetize (1.9.0) + money (~> 6.12) + money (6.12.0) + i18n (>= 0.6.4, < 1.1) + money-rails (1.12.0) activesupport (>= 3.0) - monetize (~> 1.6.0) - money (~> 6.8.1) + monetize (~> 1.9.0) + money (~> 6.12.0) railties (>= 3.0) multi_json (1.13.1) mustermann (1.0.2) @@ -397,7 +397,7 @@ GEM rack (~> 1.5) rack-protection (~> 1.4) tilt (>= 1.3, < 3) - sixarm_ruby_unaccent (1.1.1) + sixarm_ruby_unaccent (1.2.0) slop (3.6.0) socksify (1.7.1) sprockets (3.7.2) @@ -508,4 +508,4 @@ DEPENDENCIES whenever (= 0.9.4) BUNDLED WITH - 1.16.2 + 1.16.4 diff --git a/config/initializers/money.rb b/config/initializers/money.rb index bd14a3f3d..cb476b589 100644 --- a/config/initializers/money.rb +++ b/config/initializers/money.rb @@ -1,69 +1,4 @@ -# encoding : utf-8 - MoneyRails.configure do |config| - # To set the default currency - # + # Wrapper for Money#default_currency with additional functionality config.default_currency = :eur - - # Set default bank object - # - # Example: - # config.default_bank = EuCentralBank.new - - # Add exchange rates to current money bank object. - # (The conversion rate refers to one direction only) - # - # Example: - # config.add_rate "USD", "CAD", 1.24515 - # config.add_rate "CAD", "USD", 0.803115 - - # To handle the inclusion of validations for monetized fields - # The default value is true - # - # config.include_validations = true - - # Default ActiveRecord migration configuration values for columns: - # - # config.amount_column = { prefix: '', # column name prefix - # postfix: '_cents', # column name postfix - # column_name: nil, # full column name (overrides prefix, postfix and accessor name) - # type: :integer, # column type - # present: true, # column will be created - # null: false, # other options will be treated as column options - # default: 0 - # } - # - # config.currency_column = { prefix: '', - # postfix: '_currency', - # column_name: nil, - # type: :string, - # present: true, - # null: false, - # default: 'USD' - # } - - # Register a custom currency - # - # Example: - # config.register_currency = { - # :priority => 1, - # :iso_code => "EU4", - # :name => "Euro with subunit of 4 digits", - # :symbol => "€", - # :symbol_first => true, - # :subunit => "Subcent", - # :subunit_to_unit => 10000, - # :thousands_separator => ".", - # :decimal_mark => "," - # } - - # Set default money format globally. - # Default value is nil meaning "ignore this option". - # Example: - # - # config.default_format = { - # :no_cents_if_whole => nil, - # :symbol => nil, - # :sign_before_symbol => nil - # } -end +end \ No newline at end of file diff --git a/test/learning/money_test.rb b/test/learning/money_test.rb new file mode 100644 index 000000000..89fdeb917 --- /dev/null +++ b/test/learning/money_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class MoneyLearningTest < ActiveSupport::TestCase + def test_default_currency_is_euro + money = Money.from_amount(1) + assert_equal Money::Currency.new(:eur), money.currency + end +end \ No newline at end of file From b5a63aab3417ec67fc9973ef3d6366de591164d6 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Wed, 19 Sep 2018 18:33:55 +0300 Subject: [PATCH 35/37] Update rubyzip gem --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 29ca2aa28..cc5fc4511 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -360,7 +360,7 @@ GEM rspec-support (3.6.0) ruby_parser (3.8.4) sexp_processor (~> 4.1) - rubyzip (1.2.1) + rubyzip (1.2.2) safe_yaml (1.0.4) sass (3.4.23) sass-rails (5.0.6) From 03b3f9a276f4b2f01d2d89fced924aceedac44f2 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 20 Sep 2018 13:39:35 +0300 Subject: [PATCH 36/37] Make the check against billing email set from form --- app/mailers/invoice_mailer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/mailers/invoice_mailer.rb b/app/mailers/invoice_mailer.rb index c3eb20f6f..7f19deb0b 100644 --- a/app/mailers/invoice_mailer.rb +++ b/app/mailers/invoice_mailer.rb @@ -4,8 +4,10 @@ class InvoiceMailer < ApplicationMailer def invoice_email(invoice_id, html, billing_email) @invoice = Invoice.find_by(id: invoice_id) billing_email ||= @invoice.billing_email + logger.info "Billing email from form: #{billing_email}" + logger.info "Billing email from invoice database: #{@invoice.billing_email || nil}" return unless @invoice - return if whitelist_blocked?(@invoice.billing_email) + return if whitelist_blocked?(billing_email) kit = PDFKit.new(html) pdf = kit.to_pdf From bb82f47e233072e5edc1d75ee702840bda704fdc Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 20 Sep 2018 13:47:19 +0300 Subject: [PATCH 37/37] Remove additional logger messages --- app/mailers/invoice_mailer.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/mailers/invoice_mailer.rb b/app/mailers/invoice_mailer.rb index 7f19deb0b..74821c25a 100644 --- a/app/mailers/invoice_mailer.rb +++ b/app/mailers/invoice_mailer.rb @@ -4,8 +4,6 @@ class InvoiceMailer < ApplicationMailer def invoice_email(invoice_id, html, billing_email) @invoice = Invoice.find_by(id: invoice_id) billing_email ||= @invoice.billing_email - logger.info "Billing email from form: #{billing_email}" - logger.info "Billing email from invoice database: #{@invoice.billing_email || nil}" return unless @invoice return if whitelist_blocked?(billing_email)