From d6dd4eccf57329349cada479f5168d80ac595181 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 10 Feb 2020 14:35:48 +0500 Subject: [PATCH 01/17] Check if Directo counter is in range See #277 --- app/models/directo.rb | 7 ++++--- test/models/directo_test.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/models/directo.rb b/app/models/directo.rb index 789db64b2..5d57bef78 100644 --- a/app/models/directo.rb +++ b/app/models/directo.rb @@ -65,7 +65,7 @@ class Directo < ApplicationRecord def self.send_monthly_invoices(debug: false) - I18n.locale = :et + I18n.locale = :et unless Rails.env.test? month = Time.now - 1.month invoices_until = month.end_of_month date_format = "%Y-%m-%d" @@ -74,8 +74,9 @@ class Directo < ApplicationRecord min_directo = Setting.directo_monthly_number_min.presence.try(:to_i) max_directo = Setting.directo_monthly_number_max.presence.try(:to_i) last_directo = [Setting.directo_monthly_number_last.presence.try(:to_i), min_directo].compact.max || 0 - if max_directo && max_directo <= last_directo - raise "Directo counter is out of period (max allowed number is smaller than last counter number)" + if max_directo && (max_directo <= last_directo + Registrar.count) + raise 'Directo counter is out of period (max allowed number is smaller than last counter'\ + 'number plus Registrar\'s count)' end directo_next = last_directo diff --git a/test/models/directo_test.rb b/test/models/directo_test.rb index 9dbbf64d4..f1c5cce76 100644 --- a/test/models/directo_test.rb +++ b/test/models/directo_test.rb @@ -5,6 +5,19 @@ class DirectoTest < ActiveSupport::TestCase @invoice = invoices(:one) end + def test_monthly_invoices_max_range_raises_if_overlaps + + Setting.directo_monthly_number_max = Setting.directo_monthly_number_last.to_i + Registrar.count - 1 + error_message = 'Directo counter is out of period (max allowed number is smaller than last '\ + 'counternumber plus Registrar\'s count)' + + error = assert_raises RuntimeError do + Directo.send_monthly_invoices + end + + assert_equal error_message, error.message + end + def test_xml_is_include_transaction_date @invoice.update(total: @invoice.account_activity.bank_transaction.sum) @invoice.account_activity.bank_transaction.update(paid_at: Time.zone.now) From adba253d01d04972e44b217669336d92723465f0 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Mon, 17 Feb 2020 15:55:46 +0500 Subject: [PATCH 02/17] Add client_hold action to xml console See #1481 --- .../epp_requests/domain/client_hold.xml | 15 +++++++++++++++ app/views/registrar/xml_consoles/show.haml | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml b/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml new file mode 100644 index 000000000..fcafec538 --- /dev/null +++ b/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml @@ -0,0 +1,15 @@ + + + + + + example.ee + + + + + + timo-1579351654 + + diff --git a/app/views/registrar/xml_consoles/show.haml b/app/views/registrar/xml_consoles/show.haml index f96b67738..5ffcb5279 100644 --- a/app/views/registrar/xml_consoles/show.haml +++ b/app/views/registrar/xml_consoles/show.haml @@ -29,6 +29,9 @@ , %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'delete'}} Delete + , + %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'client_hold'}} + Client Hold %h4 Poll %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'poll', epp_action: 'poll'}} From 2663c550fa1aee229679e9d407b12b5a2a5c0369 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Tue, 4 Feb 2020 16:00:24 +0500 Subject: [PATCH 03/17] Add idempotent Que job for e-invoice sending --- app/jobs/send_e_invoice_job.rb | 39 +++++++++++++++++++ ...103125_add_e_invoice_sent_at_to_invoice.rb | 5 +++ db/structure.sql | 4 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200204103125_add_e_invoice_sent_at_to_invoice.rb diff --git a/app/jobs/send_e_invoice_job.rb b/app/jobs/send_e_invoice_job.rb index e69de29bb..9e8af7c65 100644 --- a/app/jobs/send_e_invoice_job.rb +++ b/app/jobs/send_e_invoice_job.rb @@ -0,0 +1,39 @@ +class SendEInvoiceJob < Que::Job + + def run(invoice) + return if invoice.e_invoice_sent_at + + e_invoice = invoice.to_e_invoice + e_invoice.deliver + + ActiveRecord::Base.transaction do + invoice.update(e_invoice_sent_at: Time.zone.now) + log_success(invoice) + destroy + end + + rescue Savon::Error => e + log_error(invoice: invoice, error: e) + end + + private + + def log_success(invoice) + message = "E-Invoice for an invoice with ID # #{invoice.id} was sent successfully" + logger.info message + end + + def log_error(invoice:, error:) + message = <<~TEXT.squish + There was an error sending e-invoice for invoice with ID # #{invoice.id}. + The error message was the following: #{error}. + This job will retry + TEXT + logger.error message + end + + def logger + Rails.logger + end + +end diff --git a/db/migrate/20200204103125_add_e_invoice_sent_at_to_invoice.rb b/db/migrate/20200204103125_add_e_invoice_sent_at_to_invoice.rb new file mode 100644 index 000000000..e0e5f2cd0 --- /dev/null +++ b/db/migrate/20200204103125_add_e_invoice_sent_at_to_invoice.rb @@ -0,0 +1,5 @@ +class AddEInvoiceSentAtToInvoice < ActiveRecord::Migration[5.0] + def change + add_column :invoices, :e_invoice_sent_at, :datetime + end +end diff --git a/db/structure.sql b/db/structure.sql index a23623bae..cd2998c07 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -886,6 +886,7 @@ CREATE TABLE public.invoices ( in_directo boolean DEFAULT false, buyer_vat_no character varying, issue_date date NOT NULL, + e_invoice_sent_at timestamp without time zone, CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date)) ); @@ -4339,6 +4340,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20191212133136'), ('20191227110904'), ('20200113091254'), -('20200115102202'); +('20200115102202'), +('20200204103125'); From 47e601f3cdce75e1ce5e5f362cb9406c6a8cd33f Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Tue, 4 Feb 2020 16:20:07 +0500 Subject: [PATCH 04/17] Add test to check if job works --- app/jobs/send_e_invoice_job.rb | 9 ++---- app/models/registrar.rb | 3 +- test/jobs/send_e_invoice_job_test.rb | 45 ++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 test/jobs/send_e_invoice_job_test.rb diff --git a/app/jobs/send_e_invoice_job.rb b/app/jobs/send_e_invoice_job.rb index 9e8af7c65..36e024b1d 100644 --- a/app/jobs/send_e_invoice_job.rb +++ b/app/jobs/send_e_invoice_job.rb @@ -1,19 +1,17 @@ class SendEInvoiceJob < Que::Job - def run(invoice) return if invoice.e_invoice_sent_at - e_invoice = invoice.to_e_invoice - e_invoice.deliver + invoice.to_e_invoice.deliver ActiveRecord::Base.transaction do invoice.update(e_invoice_sent_at: Time.zone.now) log_success(invoice) destroy end - - rescue Savon::Error => e + rescue StandardError => e log_error(invoice: invoice, error: e) + raise e end private @@ -35,5 +33,4 @@ class SendEInvoiceJob < Que::Job def logger Rails.logger end - end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 88aa1c629..94b01517e 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -100,8 +100,7 @@ class Registrar < ApplicationRecord ] ) - e_invoice = invoice.to_e_invoice - e_invoice.deliver + SendEInvoiceJob.enqueue(invoice) invoice end diff --git a/test/jobs/send_e_invoice_job_test.rb b/test/jobs/send_e_invoice_job_test.rb new file mode 100644 index 000000000..5ea09e576 --- /dev/null +++ b/test/jobs/send_e_invoice_job_test.rb @@ -0,0 +1,45 @@ +require 'test_helper' + +class SendEInvoiceJobTest < ActiveSupport::TestCase + + def teardown + EInvoice.provider = EInvoice::Providers::TestProvider.new + EInvoice::Providers::TestProvider.deliveries.clear + end + + def test_if_invoice_is_sended + @invoice = invoices(:one) + EInvoice.provider = EInvoice::Providers::TestProvider.new + EInvoice::Providers::TestProvider.deliveries.clear + + assert_nothing_raised do + SendEInvoiceJob.enqueue(@invoice) + end + + assert_not @invoice.e_invoice_sent_at.blank? + assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count + end + + def test_if_invoice_sending_retries + @invoice = invoices(:one) + provider_config = { password: nil, + test_mode: true } + EInvoice.provider = EInvoice::Providers::OmnivaProvider.new(provider_config) + stub_request(:get, "https://testfinance.post.ee/finance/erp/erpServices.wsdl").to_timeout + + assert_raise HTTPClient::TimeoutError do + SendEInvoiceJob.enqueue(@invoice) + end + assert @invoicee_invoice_sent_at.blank? + + EInvoice.provider = EInvoice::Providers::TestProvider.new + EInvoice::Providers::TestProvider.deliveries.clear + + assert_nothing_raised do + SendEInvoiceJob.enqueue(@invoice) + end + + assert_not @invoice.e_invoice_sent_at.blank? + assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count + end +end From 187ce318a221681928e7fd3366253d134cc0803a Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 5 Feb 2020 14:24:09 +0500 Subject: [PATCH 05/17] Destroy e-invoice sending job if invoice sent, cancelled or paid --- app/jobs/send_e_invoice_job.rb | 10 ++++++---- app/models/invoice.rb | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/jobs/send_e_invoice_job.rb b/app/jobs/send_e_invoice_job.rb index 36e024b1d..6e7b5edb8 100644 --- a/app/jobs/send_e_invoice_job.rb +++ b/app/jobs/send_e_invoice_job.rb @@ -1,6 +1,6 @@ class SendEInvoiceJob < Que::Job def run(invoice) - return if invoice.e_invoice_sent_at + destroy if invoice.do_not_send_e_invoice? invoice.to_e_invoice.deliver @@ -9,7 +9,7 @@ class SendEInvoiceJob < Que::Job log_success(invoice) destroy end - rescue StandardError => e + rescue Exception => e log_error(invoice: invoice, error: e) raise e end @@ -17,13 +17,15 @@ class SendEInvoiceJob < Que::Job private def log_success(invoice) - message = "E-Invoice for an invoice with ID # #{invoice.id} was sent successfully" + id = invoice.try(:id) || invoice + message = "E-Invoice for an invoice with ID # #{id} was sent successfully" logger.info message end def log_error(invoice:, error:) + id = invoice.try(:id) || invoice message = <<~TEXT.squish - There was an error sending e-invoice for invoice with ID # #{invoice.id}. + There was an error sending e-invoice for invoice with ID # #{id}. The error message was the following: #{error}. This job will retry TEXT diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 7f1dea825..4b35b71fb 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -102,6 +102,14 @@ class Invoice < ApplicationRecord generator.generate end + def do_not_send_e_invoice? + e_invoice_sent? || cancelled? || paid? + end + + def e_invoice_sent? + e_invoice_sent_at.present? + end + private def apply_default_buyer_vat_no @@ -111,4 +119,4 @@ class Invoice < ApplicationRecord def calculate_total self.total = subtotal + vat_amount end -end \ No newline at end of file +end From a743c6c56f11e8c6f9cf6e0692a18c2ab8e4a396 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Wed, 19 Feb 2020 11:08:54 +0200 Subject: [PATCH 06/17] disable airbrake performance monitoring --- config/initializers/airbrake.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/initializers/airbrake.rb b/config/initializers/airbrake.rb index 917deb02a..5c1983369 100644 --- a/config/initializers/airbrake.rb +++ b/config/initializers/airbrake.rb @@ -3,6 +3,9 @@ Airbrake.configure do |config| config.project_id = ENV['airbrake_project_id'] config.project_key = ENV['airbrake_project_key'] config.root_directory = Rails.root + config.job_stats = false + config.query_stats = false + config.performance_stats = false config.logger = if ENV['RAILS_LOG_TO_STDOUT'].present? Logger.new(STDOUT, level: Rails.logger.level) From 3b332da0bb27160ac07414e5911f000eddbf6c82 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 19 Feb 2020 14:09:45 +0500 Subject: [PATCH 07/17] Add remove clientHold to registrar UI --- app/controllers/registrar/domains_controller.rb | 8 ++++++++ app/models/ability.rb | 1 + app/models/concerns/domain/force_delete.rb | 4 ++++ app/models/concerns/remove_hold.rb | 9 +++++++++ app/models/depp/domain.rb | 1 + app/views/registrar/domains/_domain.html.erb | 4 ++++ config/locales/en.yml | 1 + config/locales/registrar/domains.en.yml | 1 + config/routes.rb | 1 + 9 files changed, 30 insertions(+) create mode 100644 app/models/concerns/remove_hold.rb diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index 5bf1a51f5..8fdfd51fd 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -153,6 +153,14 @@ class Registrar render json: scope.pluck(:name, :code).map { |c| { display_key: "#{c.second} #{c.first}", value: c.second } } end + def remove_hold + authorize! :remove_hold, Depp::Domain + return unless params[:domain_name] + + @data = @domain.remove_hold(params) + redirect_to info_registrar_domains_url(domain_name: params[:domain_name]) + end + private def init_domain diff --git a/app/models/ability.rb b/app/models/ability.rb index 9a0676ac8..a727254ad 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -50,6 +50,7 @@ class Ability can(:check, Epp::Domain) can(:create, Epp::Domain) can(:renew, Epp::Domain) { |d| d.registrar_id == @user.registrar_id } + can(:remove_hold, Epp::Domain) { |d| d.registrar_id == @user.registrar_id } can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw } can(:transfer, Epp::Domain) can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw } diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb index af3aaa7c7..89c121993 100644 --- a/app/models/concerns/domain/force_delete.rb +++ b/app/models/concerns/domain/force_delete.rb @@ -34,6 +34,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength force_delete_start.present? && force_delete_lte_today && force_delete_lte_valid_date end + def client_holded? + statuses.include?(DomainStatus::CLIENT_HOLD) + end + def force_delete_lte_today force_delete_start + Setting.expire_warning_period.days <= Time.zone.now end diff --git a/app/models/concerns/remove_hold.rb b/app/models/concerns/remove_hold.rb new file mode 100644 index 000000000..1da3b5a7f --- /dev/null +++ b/app/models/concerns/remove_hold.rb @@ -0,0 +1,9 @@ +module RemoveHold + extend ActiveSupport::Concern + + def remove_hold(params) + xml = epp_xml.update(name: { value: params[:domain_name] }, + rem: [status: { attrs: { s: 'clientHold' }, value: '' }]) + current_user.request(xml) + end +end diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index e2413a004..3bb3b7473 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -1,6 +1,7 @@ module Depp class Domain include ActiveModel::Conversion + include RemoveHold extend ActiveModel::Naming attr_accessor :name, :current_user, :epp_xml diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb index 74f29dc15..d8910a490 100644 --- a/app/views/registrar/domains/_domain.html.erb +++ b/app/views/registrar/domains/_domain.html.erb @@ -9,5 +9,9 @@ class: 'btn btn-default btn-xs' %> <%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> + <% if domain.client_holded? %> + <%= link_to t('.client_hold_btn'), remove_hold_registrar_domains_path(domain_name: domain.name), + class: 'btn btn-default btn-xs' %> + <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 74040fe98..15deab604 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -580,6 +580,7 @@ en: tech: Tech contact valid: Valid object_is_not_eligible_for_renewal: 'Object is not eligible for renewal' + object_is_not_holded: 'Object is not holded' bank_statement_desc: 'Import file row will match only when matching following attributes:
ref number
payment amount
invoice number (the first numerical value in comment field)
.' create_bank_statement: 'Create bank statement' create_bank_transaction: 'Create bank transaction' diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index c98002b8f..2f5d83240 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -24,6 +24,7 @@ en: edit_btn: Edit renew_btn: Renew delete_btn: Delete + client_hold_btn: Remove Hold form: save_btn: Save diff --git a/config/routes.rb b/config/routes.rb index 135fe8eb0..8315e78ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,7 @@ Rails.application.routes.draw do get 'check' get 'delete' get 'search_contacts' + get 'remove_hold' end end resources :domain_transfers, only: %i[new create] From 1d6040cd5bdf8c0a6ee02b4a686f42a01a6041a3 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 19 Feb 2020 17:47:13 +0500 Subject: [PATCH 08/17] Fix async que job calling --- app/jobs/send_e_invoice_job.rb | 17 +++++++++++------ app/models/registrar.rb | 3 +-- test/jobs/send_e_invoice_job_test.rb | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/jobs/send_e_invoice_job.rb b/app/jobs/send_e_invoice_job.rb index 6e7b5edb8..e281db14d 100644 --- a/app/jobs/send_e_invoice_job.rb +++ b/app/jobs/send_e_invoice_job.rb @@ -1,21 +1,26 @@ class SendEInvoiceJob < Que::Job - def run(invoice) - destroy if invoice.do_not_send_e_invoice? + def run(invoice_id) + invoice = run_condition(Invoice.find_by(id: invoice_id)) invoice.to_e_invoice.deliver - ActiveRecord::Base.transaction do invoice.update(e_invoice_sent_at: Time.zone.now) log_success(invoice) destroy end - rescue Exception => e + rescue StandardError => e log_error(invoice: invoice, error: e) raise e end private + def run_condition(invoice) + destroy unless invoice + destroy if invoice.do_not_send_e_invoice? + invoice + end + def log_success(invoice) id = invoice.try(:id) || invoice message = "E-Invoice for an invoice with ID # #{id} was sent successfully" @@ -26,8 +31,8 @@ class SendEInvoiceJob < Que::Job id = invoice.try(:id) || invoice message = <<~TEXT.squish There was an error sending e-invoice for invoice with ID # #{id}. - The error message was the following: #{error}. - This job will retry + The error message was the following: #{error} + This job will retry. TEXT logger.error message end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 94b01517e..f657cdc74 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -99,8 +99,7 @@ class Registrar < ApplicationRecord } ] ) - - SendEInvoiceJob.enqueue(invoice) + SendEInvoiceJob.enqueue(invoice.id) invoice end diff --git a/test/jobs/send_e_invoice_job_test.rb b/test/jobs/send_e_invoice_job_test.rb index 5ea09e576..384479e92 100644 --- a/test/jobs/send_e_invoice_job_test.rb +++ b/test/jobs/send_e_invoice_job_test.rb @@ -13,8 +13,9 @@ class SendEInvoiceJobTest < ActiveSupport::TestCase EInvoice::Providers::TestProvider.deliveries.clear assert_nothing_raised do - SendEInvoiceJob.enqueue(@invoice) + SendEInvoiceJob.enqueue(@invoice.id) end + @invoice.reload assert_not @invoice.e_invoice_sent_at.blank? assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count @@ -28,7 +29,7 @@ class SendEInvoiceJobTest < ActiveSupport::TestCase stub_request(:get, "https://testfinance.post.ee/finance/erp/erpServices.wsdl").to_timeout assert_raise HTTPClient::TimeoutError do - SendEInvoiceJob.enqueue(@invoice) + SendEInvoiceJob.enqueue(@invoice.id) end assert @invoicee_invoice_sent_at.blank? @@ -36,8 +37,9 @@ class SendEInvoiceJobTest < ActiveSupport::TestCase EInvoice::Providers::TestProvider.deliveries.clear assert_nothing_raised do - SendEInvoiceJob.enqueue(@invoice) + SendEInvoiceJob.enqueue(@invoice.id) end + @invoice.reload assert_not @invoice.e_invoice_sent_at.blank? assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count From 5ec2d25ec573e0feff982c9e244a99ebe18f01be Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 19 Feb 2020 18:39:18 +0500 Subject: [PATCH 09/17] Move Remove clientHold button to domain info --- app/controllers/registrar/domains_controller.rb | 7 +++++++ app/models/concerns/domain/force_delete.rb | 4 ---- app/views/registrar/domains/_domain.html.erb | 4 ---- app/views/registrar/domains/info.html.erb | 4 ++++ app/views/registrar/xml_consoles/show.haml | 2 +- config/locales/en.yml | 1 + config/locales/registrar/domains.en.yml | 1 - 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index 8fdfd51fd..3e721666b 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -59,6 +59,7 @@ class Registrar def info authorize! :info, Depp::Domain @data = @domain.info(params[:domain_name]) if params[:domain_name] + @client_holded = client_holded(@data) if response_ok? render 'info' else @@ -158,6 +159,8 @@ class Registrar return unless params[:domain_name] @data = @domain.remove_hold(params) + + flash[:alert] = @data.css('msg').text unless response_ok? redirect_to info_registrar_domains_url(domain_name: params[:domain_name]) end @@ -167,6 +170,10 @@ class Registrar @domain = Depp::Domain.new(current_user: depp_current_user) end + def client_holded(data) + data.css('status')&.map { |element| element.attribute('s').value } + &.any? { |status| status == DomainStatus::CLIENT_HOLD } + end def contacts current_registrar_user.registrar.contacts diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb index 89c121993..af3aaa7c7 100644 --- a/app/models/concerns/domain/force_delete.rb +++ b/app/models/concerns/domain/force_delete.rb @@ -34,10 +34,6 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength force_delete_start.present? && force_delete_lte_today && force_delete_lte_valid_date end - def client_holded? - statuses.include?(DomainStatus::CLIENT_HOLD) - end - def force_delete_lte_today force_delete_start + Setting.expire_warning_period.days <= Time.zone.now end diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb index d8910a490..74f29dc15 100644 --- a/app/views/registrar/domains/_domain.html.erb +++ b/app/views/registrar/domains/_domain.html.erb @@ -9,9 +9,5 @@ class: 'btn btn-default btn-xs' %> <%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> - <% if domain.client_holded? %> - <%= link_to t('.client_hold_btn'), remove_hold_registrar_domains_path(domain_name: domain.name), - class: 'btn btn-default btn-xs' %> - <% end %> diff --git a/app/views/registrar/domains/info.html.erb b/app/views/registrar/domains/info.html.erb index 1fcfc23c3..e88882233 100644 --- a/app/views/registrar/domains/info.html.erb +++ b/app/views/registrar/domains/info.html.erb @@ -6,6 +6,10 @@ class: 'btn btn-default') %> <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]), class: 'btn btn-default') %> + <% if @client_holded %> + <%= link_to(t(:remove_client_hold), remove_hold_registrar_domains_path(domain_name: params[:domain_name]), + class: 'btn btn-default') %> + <% end %> <% else %> <%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path(domain_name: params[:domain_name]), class: 'btn btn-default' %> diff --git a/app/views/registrar/xml_consoles/show.haml b/app/views/registrar/xml_consoles/show.haml index 5ffcb5279..bb66116ee 100644 --- a/app/views/registrar/xml_consoles/show.haml +++ b/app/views/registrar/xml_consoles/show.haml @@ -31,7 +31,7 @@ Delete , %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'client_hold'}} - Client Hold + Remove Client Hold %h4 Poll %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'poll', epp_action: 'poll'}} diff --git a/config/locales/en.yml b/config/locales/en.yml index 15deab604..cf72b1027 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -206,6 +206,7 @@ en: statuses: 'Statuses' description: 'Description' delete: 'Delete' + remove_client_hold: 'Remove clientHold' are_you_sure: 'Are you sure?' back: 'Back' new_domain: 'New domain' diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 2f5d83240..c98002b8f 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -24,7 +24,6 @@ en: edit_btn: Edit renew_btn: Renew delete_btn: Delete - client_hold_btn: Remove Hold form: save_btn: Save From afa455988dce4a7776574e31cb0443b7d0a41ef7 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Thu, 20 Feb 2020 19:46:23 +0200 Subject: [PATCH 10/17] bump ruby version to 2.6.5 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index ec1cf33c3..57cf282eb 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.3 +2.6.5 From 916546ad867aa909975bd33290a254830588a34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 20 Feb 2020 20:45:17 +0200 Subject: [PATCH 11/17] Update CHANGELOG.md [ci skip] --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b723101ec..b5409f2f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +20.02.2020 +* E-invoice sending to Que to manage resending in case of an error [#1509](https://github.com/internetee/registry/issues/1509) +* Check to make sure all monthly invoices fit in available invoice number range [#277](https://github.com/internetee/registry/issues/277) +* Disabled aurbreak performance monitoring [#1534](https://github.com/internetee/registry/pull/1534) + 14.02.2020 * Fixed Papertrail warnings [#1530](https://github.com/internetee/registry/issues/1530) From e81e24ff238f834cbe22b1a3c1c9c5ddb031fe67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2020 20:19:46 +0000 Subject: [PATCH 12/17] Bump nokogiri from 1.10.7 to 1.10.8 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.7 to 1.10.8. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.7...v1.10.8) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index fad531c26..b67273812 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -269,7 +269,7 @@ GEM mustermann (>= 1.0.0) netrc (0.11.0) nio4r (2.5.2) - nokogiri (1.10.7) + nokogiri (1.10.8) mini_portile2 (~> 2.4.0) nori (2.6.0) open4 (1.3.4) From 4ddbb08e80879fcf365120b1ad897f9c97675ba7 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Tue, 25 Feb 2020 14:19:24 +0500 Subject: [PATCH 13/17] Move data migrations from rake tasks to gem See #1298 --- Gemfile | 2 +- Gemfile.lock | 2 +- .../20150601083516_add_cert_common_name.rb | 19 +++--- db/data/20150601083800_add_cert_md5.rb | 43 +++++++------ db/data/20150609093515_add_renew_setting.rb | 5 +- db/data/20150610111019_add_expire_settings.rb | 7 +-- ...20150612125720_refactor_domain_statuses.rb | 17 +++--- ...0150707103801_refactor_contact_statuses.rb | 17 +++--- ...200225085234_convert_domain_delete_date.rb | 19 ++++++ ...elete_orphaned_registrant_verifications.rb | 18 ++++++ ..._regenerate_registrar_reference_numbers.rb | 19 ++++++ db/data_schema.rb | 2 + lib/tasks/data_migrations/.keep | 0 .../convert_domain_delete_date.rake | 16 ----- ...ete_orphaned_registrant_verifications.rake | 15 ----- ...egenerate_registrar_reference_numbers.rake | 16 ----- ...nerate_registrar_reference_numbers_test.rb | 61 ------------------- .../convert_domain_delete_date_test.rb | 61 ------------------- ..._orphaned_registrant_verifications_test.rb | 43 ------------- 19 files changed, 111 insertions(+), 271 deletions(-) create mode 100644 db/data/20200225085234_convert_domain_delete_date.rb create mode 100644 db/data/20200225085433_delete_orphaned_registrant_verifications.rb create mode 100644 db/data/20200225085539_regenerate_registrar_reference_numbers.rb create mode 100644 db/data_schema.rb create mode 100644 lib/tasks/data_migrations/.keep delete mode 100644 lib/tasks/data_migrations/convert_domain_delete_date.rake delete mode 100644 lib/tasks/data_migrations/delete_orphaned_registrant_verifications.rake delete mode 100644 lib/tasks/data_migrations/regenerate_registrar_reference_numbers.rake delete mode 100644 test/integration/tasks/data_migrations/regenerate_registrar_reference_numbers_test.rb delete mode 100644 test/tasks/data_migrations/convert_domain_delete_date_test.rb delete mode 100644 test/tasks/data_migrations/delete_orphaned_registrant_verifications_test.rb diff --git a/Gemfile b/Gemfile index cab5e0dd6..7b9ee143d 100644 --- a/Gemfile +++ b/Gemfile @@ -36,10 +36,10 @@ gem 'devise', '~> 4.7' gem 'grape' # registry specfic +gem 'data_migrate', '~> 6.1' gem 'isikukood' # for EE-id validation gem 'simpleidn', '0.0.9' # For punycode gem 'money-rails' -gem 'data_migrate' gem 'whenever', '0.9.4', require: false # country listing diff --git a/Gemfile.lock b/Gemfile.lock index b67273812..5053b9468 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -462,7 +462,7 @@ DEPENDENCIES company_register! countries daemons-rails (= 1.2.1) - data_migrate + data_migrate (~> 6.1) database_cleaner devise (~> 4.7) digidoc_client! diff --git a/db/data/20150601083516_add_cert_common_name.rb b/db/data/20150601083516_add_cert_common_name.rb index ef401b871..d0959e5b7 100644 --- a/db/data/20150601083516_add_cert_common_name.rb +++ b/db/data/20150601083516_add_cert_common_name.rb @@ -1,16 +1,15 @@ -class AddCertCommonName < ActiveRecord::Migration +class AddCertCommonName < ActiveRecord::Migration[5.1] def self.up - Certificate.all.each do |x| - if x.crt.blank? && x.csr.present? - pc = x.parsed_csr.try(:subject).try(:to_s) || '' - cn = pc.scan(/\/CN=(.+)/).flatten.first - x.common_name = cn.split('/').first - end - x.save - end + # Certificate.all.each do |x| + # if x.crt.blank? && x.csr.present? + # pc = x.parsed_csr.try(:subject).try(:to_s) || '' + # cn = pc.scan(/\/CN=(.+)/).flatten.first + # x.common_name = cn.split('/').first + # end + # x.save + # end end def self.down - raise ActiveRecord::IrreversibleMigration end end diff --git a/db/data/20150601083800_add_cert_md5.rb b/db/data/20150601083800_add_cert_md5.rb index 5efe4e596..4db005177 100644 --- a/db/data/20150601083800_add_cert_md5.rb +++ b/db/data/20150601083800_add_cert_md5.rb @@ -1,28 +1,27 @@ -class AddCertMd5 < ActiveRecord::Migration +class AddCertMd5 < ActiveRecord::Migration[5.1] def self.up - Certificate.all.each do |x| - if x.crt.present? && x.csr.present? - x.interface = Certificate::REGISTRAR - x.md5 = OpenSSL::Digest::MD5.new(x.parsed_crt.to_der).to_s - - pc = x.parsed_crt.try(:subject).try(:to_s) || '' - cn = pc.scan(/\/CN=(.+)/).flatten.first - x.common_name = cn.split('/').first - elsif x.crt.present? && x.csr.blank? - x.interface = Certificate::API - x.md5 = OpenSSL::Digest::MD5.new(x.parsed_crt.to_der).to_s - - pc = x.parsed_crt.try(:subject).try(:to_s) || '' - cn = pc.scan(/\/CN=(.+)/).flatten.first - x.common_name = cn.split('/').first - elsif x.crt.blank? && x.csr.present? - x.interface = Certificate::REGISTRAR - end - x.save - end + # Certificate.all.each do |x| + # if x.crt.present? && x.csr.present? + # x.interface = Certificate::REGISTRAR + # x.md5 = OpenSSL::Digest::MD5.new(x.parsed_crt.to_der).to_s + # + # pc = x.parsed_crt.try(:subject).try(:to_s) || '' + # cn = pc.scan(/\/CN=(.+)/).flatten.first + # x.common_name = cn.split('/').first + # elsif x.crt.present? && x.csr.blank? + # x.interface = Certificate::API + # x.md5 = OpenSSL::Digest::MD5.new(x.parsed_crt.to_der).to_s + # + # pc = x.parsed_crt.try(:subject).try(:to_s) || '' + # cn = pc.scan(/\/CN=(.+)/).flatten.first + # x.common_name = cn.split('/').first + # elsif x.crt.blank? && x.csr.present? + # x.interface = Certificate::REGISTRAR + # end + # x.save + # end end def self.down - raise ActiveRecord::IrreversibleMigration end end diff --git a/db/data/20150609093515_add_renew_setting.rb b/db/data/20150609093515_add_renew_setting.rb index f462c38cb..2d99aa448 100644 --- a/db/data/20150609093515_add_renew_setting.rb +++ b/db/data/20150609093515_add_renew_setting.rb @@ -1,9 +1,8 @@ -class AddRenewSetting < ActiveRecord::Migration +class AddRenewSetting < ActiveRecord::Migration[5.1] def self.up - Setting.days_to_renew_domain_before_expire = 90 + # Setting.days_to_renew_domain_before_expire = 90 end def self.down - raise ActiveRecord::IrreversibleMigration end end diff --git a/db/data/20150610111019_add_expire_settings.rb b/db/data/20150610111019_add_expire_settings.rb index 9f8b9cce8..6171536dd 100644 --- a/db/data/20150610111019_add_expire_settings.rb +++ b/db/data/20150610111019_add_expire_settings.rb @@ -1,10 +1,9 @@ -class AddExpireSettings < ActiveRecord::Migration +class AddExpireSettings < ActiveRecord::Migration[5.1] def self.up - Setting.expire_warning_period = 15 - Setting.redemption_grace_period = 30 + # Setting.expire_warning_period = 15 + # Setting.redemption_grace_period = 30 end def self.down - raise ActiveRecord::IrreversibleMigration end end diff --git a/db/data/20150612125720_refactor_domain_statuses.rb b/db/data/20150612125720_refactor_domain_statuses.rb index 00e87b4d0..de0733e3f 100644 --- a/db/data/20150612125720_refactor_domain_statuses.rb +++ b/db/data/20150612125720_refactor_domain_statuses.rb @@ -1,15 +1,14 @@ -class RefactorDomainStatuses < ActiveRecord::Migration +class RefactorDomainStatuses < ActiveRecord::Migration[5.1] def self.up - Domain.find_each do |x| - statuses = [] - x.domain_statuses.each do |ds| - statuses << ds.value - end - x.update_column('statuses', statuses) - end + # Domain.find_each do |x| + # statuses = [] + # x.domain_statuses.each do |ds| + # statuses << ds.value + # end + # x.update_column('statuses', statuses) if x.statuses.blank? + # end end def self.down - raise ActiveRecord::IrreversibleMigration end end diff --git a/db/data/20150707103801_refactor_contact_statuses.rb b/db/data/20150707103801_refactor_contact_statuses.rb index be6312016..e1833dd66 100644 --- a/db/data/20150707103801_refactor_contact_statuses.rb +++ b/db/data/20150707103801_refactor_contact_statuses.rb @@ -1,15 +1,14 @@ -class RefactorContactStatuses < ActiveRecord::Migration +class RefactorContactStatuses < ActiveRecord::Migration[5.1] def self.up - Contact.find_each do |contact| - statuses = [] - contact.depricated_statuses.each do |ds| - statuses << ds.value - end - contact.update_column('statuses', statuses) - end + # Contact.find_each do |contact| + # statuses = [] + # contact.depricated_statuses.each do |ds| + # statuses << ds.value + # end + # contact.update_column('statuses', statuses) + # end end def self.down - raise ActiveRecord::IrreversibleMigration end end diff --git a/db/data/20200225085234_convert_domain_delete_date.rb b/db/data/20200225085234_convert_domain_delete_date.rb new file mode 100644 index 000000000..81f070927 --- /dev/null +++ b/db/data/20200225085234_convert_domain_delete_date.rb @@ -0,0 +1,19 @@ +class ConvertDomainDeleteDate < ActiveRecord::Migration[5.1] + def up + # processed_domain_count = 0 + # + # Domain.transaction do + # Domain.find_each do |domain| + # next unless domain.delete_date + # + # domain.update_columns(delete_date: domain.delete_date + 1.day) + # processed_domain_count += 1 + # end + # end + # + # puts "Domains processed: #{processed_domain_count}" + end + + def down + end +end diff --git a/db/data/20200225085433_delete_orphaned_registrant_verifications.rb b/db/data/20200225085433_delete_orphaned_registrant_verifications.rb new file mode 100644 index 000000000..73c270a6a --- /dev/null +++ b/db/data/20200225085433_delete_orphaned_registrant_verifications.rb @@ -0,0 +1,18 @@ +class DeleteOrphanedRegistrantVerifications < ActiveRecord::Migration[5.1] + def up + # orphaned_registrant_verifications = RegistrantVerification.where.not(domain_id: Domain.ids) + # orphaned_registrant_verification_count = orphaned_registrant_verifications.count + # processed_registrant_verification_count = 0 + # + # orphaned_registrant_verifications.each do |registrant_verification| + # registrant_verification.destroy! + # processed_registrant_verification_count += 1 + # end + # + # puts "Processed: #{processed_registrant_verification_count} out of" \ + # " #{orphaned_registrant_verification_count}" + end + + def down + end +end diff --git a/db/data/20200225085539_regenerate_registrar_reference_numbers.rb b/db/data/20200225085539_regenerate_registrar_reference_numbers.rb new file mode 100644 index 000000000..fbd2a5c5f --- /dev/null +++ b/db/data/20200225085539_regenerate_registrar_reference_numbers.rb @@ -0,0 +1,19 @@ +class RegenerateRegistrarReferenceNumbers < ActiveRecord::Migration[5.1] + def up + # processed_registrar_count = 0 + # + # Registrar.transaction do + # Registrar.all.each do |registrar| + # next unless registrar.reference_no.start_with?('RF') + # + # registrar.update_columns(reference_no: Billing::ReferenceNo.generate) + # processed_registrar_count += 1 + # end + # end + # + # puts "Registrars processed: #{processed_registrar_count}" + end + + def down + end +end diff --git a/db/data_schema.rb b/db/data_schema.rb new file mode 100644 index 000000000..f4a3f5d8a --- /dev/null +++ b/db/data_schema.rb @@ -0,0 +1,2 @@ +# encoding: UTF-8 +DataMigrate::Data.define(version: 20150707103801) diff --git a/lib/tasks/data_migrations/.keep b/lib/tasks/data_migrations/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/tasks/data_migrations/convert_domain_delete_date.rake b/lib/tasks/data_migrations/convert_domain_delete_date.rake deleted file mode 100644 index 7eeee5cf0..000000000 --- a/lib/tasks/data_migrations/convert_domain_delete_date.rake +++ /dev/null @@ -1,16 +0,0 @@ -namespace :data_migrations do - task convert_domain_delete_date: :environment do - processed_domain_count = 0 - - Domain.transaction do - Domain.find_each do |domain| - next unless domain.delete_date - - domain.update_columns(delete_date: domain.delete_date + 1.day) - processed_domain_count += 1 - end - end - - puts "Domains processed: #{processed_domain_count}" - end -end \ No newline at end of file diff --git a/lib/tasks/data_migrations/delete_orphaned_registrant_verifications.rake b/lib/tasks/data_migrations/delete_orphaned_registrant_verifications.rake deleted file mode 100644 index f65db547e..000000000 --- a/lib/tasks/data_migrations/delete_orphaned_registrant_verifications.rake +++ /dev/null @@ -1,15 +0,0 @@ -namespace :data_migrations do - task delete_orphaned_registrant_verifications: :environment do - orphaned_registrant_verifications = RegistrantVerification.where.not(domain_id: Domain.ids) - orphaned_registrant_verification_count = orphaned_registrant_verifications.count - processed_registrant_verification_count = 0 - - orphaned_registrant_verifications.each do |registrant_verification| - registrant_verification.destroy! - processed_registrant_verification_count += 1 - end - - puts "Processed: #{processed_registrant_verification_count} out of" \ - " #{orphaned_registrant_verification_count}" - end -end diff --git a/lib/tasks/data_migrations/regenerate_registrar_reference_numbers.rake b/lib/tasks/data_migrations/regenerate_registrar_reference_numbers.rake deleted file mode 100644 index 6f6aaebe2..000000000 --- a/lib/tasks/data_migrations/regenerate_registrar_reference_numbers.rake +++ /dev/null @@ -1,16 +0,0 @@ -namespace :data_migrations do - task regenerate_registrar_reference_numbers: [:environment] do - processed_registrar_count = 0 - - Registrar.transaction do - Registrar.all.each do |registrar| - next unless registrar.reference_no.start_with?('RF') - - registrar.update_columns(reference_no: Billing::ReferenceNo.generate) - processed_registrar_count += 1 - end - end - - puts "Registrars processed: #{processed_registrar_count}" - end -end diff --git a/test/integration/tasks/data_migrations/regenerate_registrar_reference_numbers_test.rb b/test/integration/tasks/data_migrations/regenerate_registrar_reference_numbers_test.rb deleted file mode 100644 index 946c6b898..000000000 --- a/test/integration/tasks/data_migrations/regenerate_registrar_reference_numbers_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test_helper' - -class RegenerateRegistrarReferenceNumbersTaskTest < ActiveSupport::TestCase - def test_regenerates_registrar_reference_numbers_to_estonian_format - registrar = registrars(:bestnames) - registrar.update_column(:reference_no, 'RF1111') - - capture_io { run_task } - registrar.reload - - assert_not registrar.reference_no.start_with?('RF') - end - - def test_bypasses_registrar_validation - registrar = registrars(:invalid) - registrar.update_column(:reference_no, 'RF1111') - assert registrar.invalid? - - capture_io { run_task } - registrar.reload - - assert_not registrar.reference_no.start_with?('RF') - end - - def test_does_not_regenerate_when_the_task_is_run_again - registrar = registrars(:bestnames) - registrar.update!(reference_no: '1111') - - capture_io { run_task } - registrar.reload - - assert_equal '1111', registrar.reference_no - end - - def test_keeps_iso_reference_number_on_the_invoice_unchanged - registrar = registrars(:bestnames) - registrar.update_column(:reference_no, 'RF1111') - invoice = invoices(:one) - invoice.update!(reference_no: 'RF2222') - - capture_io { run_task } - invoice.reload - - assert_equal 'RF2222', invoice.reference_no - end - - def test_output - registrar = registrars(:bestnames) - registrar.update_column(:reference_no, 'RF1111') - - assert_output "Registrars processed: 1\n" do - run_task - end - end - - private - - def run_task - Rake::Task['data_migrations:regenerate_registrar_reference_numbers'].execute - end -end diff --git a/test/tasks/data_migrations/convert_domain_delete_date_test.rb b/test/tasks/data_migrations/convert_domain_delete_date_test.rb deleted file mode 100644 index 709334b52..000000000 --- a/test/tasks/data_migrations/convert_domain_delete_date_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'test_helper' - -class ConvertDomainDeleteDateTaskTest < ActiveSupport::TestCase - setup do - @domain = domains(:shop) - end - - def test_moves_domain_delete_date_one_day_ahead - @domain.update!(delete_date: '2010-07-05') - - capture_io do - run_task - end - @domain.reload - - assert_equal Date.parse('2010-07-06'), @domain.delete_date - end - - def test_processes_invalid_domains - @domain = domains(:invalid) - @domain.update_columns(delete_date: '2010-07-05') - - capture_io do - run_task - end - @domain.reload - - assert_equal Date.parse('2010-07-06'), @domain.delete_date - end - - def test_skips_non_expired_domains - @domain.update!(delete_date: nil) - - assert_nothing_raised do - capture_io do - run_task - end - end - end - - def test_output - eliminate_effect_of_all_domains_except(@domain) - @domain.update!(delete_date: '2010-07-05') - - assert_output "Domains processed: 1\n" do - run_task - end - end - - private - - def eliminate_effect_of_all_domains_except(domain) - Domain.connection.disable_referential_integrity do - Domain.where("id != #{domain.id}").delete_all - end - end - - def run_task - Rake::Task['data_migrations:convert_domain_delete_date'].execute - end -end \ No newline at end of file diff --git a/test/tasks/data_migrations/delete_orphaned_registrant_verifications_test.rb b/test/tasks/data_migrations/delete_orphaned_registrant_verifications_test.rb deleted file mode 100644 index df576332e..000000000 --- a/test/tasks/data_migrations/delete_orphaned_registrant_verifications_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'test_helper' - -class ArchiveOrphanedRegistrantVerificationsTest < ActiveSupport::TestCase - def test_deletes_orphaned_registrant_verifications - create_orphaned_registrant_verification - - assert_difference 'RegistrantVerification.count', -1 do - capture_io do - run_task - end - end - end - - def test_keeps_non_orphaned_registrant_verifications_intact - assert_no_difference 'RegistrantVerification.count' do - capture_io do - run_task - end - end - end - - def test_output - create_orphaned_registrant_verification - - assert_output "Processed: 1 out of 1\n" do - run_task - end - end - - private - - def create_orphaned_registrant_verification - non_existent_domain_id = 55 - assert_not_includes Domain.ids, non_existent_domain_id - - RegistrantVerification.connection.disable_referential_integrity do - registrant_verifications(:one).update_columns(domain_id: non_existent_domain_id) - end - end - - def run_task - Rake::Task['data_migrations:delete_orphaned_registrant_verifications'].execute end -end From 99c0abc5a8dfafea4c87c2dc5c4c782e453053c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 26 Feb 2020 14:53:21 +0200 Subject: [PATCH 14/17] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5409f2f5..47f8baef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +26.02.2020 +* Implemented consistent and automated data migrations [#1298](https://github.com/internetee/registry/issues/1298) + 20.02.2020 * E-invoice sending to Que to manage resending in case of an error [#1509](https://github.com/internetee/registry/issues/1509) * Check to make sure all monthly invoices fit in available invoice number range [#277](https://github.com/internetee/registry/issues/277) From b859cfc090d7c19f2197bf2664f5bd196afb180c Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Wed, 26 Feb 2020 19:30:38 +0500 Subject: [PATCH 15/17] Fix domain statuses removal Close #1543s --- app/models/domain.rb | 4 ++-- test/system/admin_area/domains_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index ceff9e810..f21317b70 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -485,9 +485,9 @@ class Domain < ApplicationRecord self.delete_date = nil when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set self.outzone_at = Time.zone.now if force_delete_scheduled? - when DomainStatus::DomainStatus::EXPIRED # removal causes server hold to set + when DomainStatus::EXPIRED # removal causes server hold to set self.outzone_at = self.expire_time + 15.day - when DomainStatus::DomainStatus::SERVER_HOLD # removal causes server hold to set + when DomainStatus::SERVER_HOLD # removal causes server hold to set self.outzone_at = nil end end diff --git a/test/system/admin_area/domains_test.rb b/test/system/admin_area/domains_test.rb index abd1d93fb..05e7d60f3 100644 --- a/test/system/admin_area/domains_test.rb +++ b/test/system/admin_area/domains_test.rb @@ -35,4 +35,15 @@ class AdminDomainsTestTest < ApplicationSystemTestCase assert_text 'deleteCandidate status has been removed' assert_no_link 'Remove deleteCandidate status' end + + def test_remove_domain_status + @domain.update!(statuses: [DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED]) + + visit edit_admin_domain_url(@domain) + + click_link_or_button 'Delete' + click_link_or_button 'Save' + + assert_text 'Domain updated!' + end end From 3e2e84f3645d02875b98f4fa6dbe4e6c9b1712c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 26 Feb 2020 17:19:11 +0200 Subject: [PATCH 16/17] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f8baef1..123ef72a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ 26.02.2020 +* Registrar: added an option to remove clientHold status [#1481](https://github.com/internetee/registry/issues/1481) * Implemented consistent and automated data migrations [#1298](https://github.com/internetee/registry/issues/1298) 20.02.2020 From f4ea9cfeffd06c23ce097a96d1a7defa1fadae15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Wed, 26 Feb 2020 17:21:56 +0200 Subject: [PATCH 17/17] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 123ef72a1..94ecb8864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 26.02.2020 * Registrar: added an option to remove clientHold status [#1481](https://github.com/internetee/registry/issues/1481) +* Admin: fixed domain status removal issue [#1543](https://github.com/internetee/registry/issues/1543) * Implemented consistent and automated data migrations [#1298](https://github.com/internetee/registry/issues/1298) 20.02.2020