mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 02:05:57 +02:00
Merge remote-tracking branch 'origin/master' into 509-directo-to-gem
This commit is contained in:
commit
86889b6432
39 changed files with 298 additions and 280 deletions
|
@ -1 +1 @@
|
|||
2.6.3
|
||||
2.6.5
|
||||
|
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,3 +1,13 @@
|
|||
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
|
||||
* 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)
|
||||
|
||||
|
|
2
Gemfile
2
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
|
||||
|
|
|
@ -9,7 +9,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: https://github.com/internetee/directo.git
|
||||
revision: c688c46134ce04f5a75b7a0563abc18cd9af030a
|
||||
revision: 6fb158c1589c609b2519d8e8658c11de52bd3d9d
|
||||
branch: directo-api
|
||||
specs:
|
||||
directo (0.1.0)
|
||||
|
@ -278,7 +278,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)
|
||||
|
@ -471,7 +471,7 @@ DEPENDENCIES
|
|||
company_register!
|
||||
countries
|
||||
daemons-rails (= 1.2.1)
|
||||
data_migrate
|
||||
data_migrate (~> 6.1)
|
||||
database_cleaner
|
||||
devise (~> 4.7)
|
||||
digidoc_client!
|
||||
|
|
|
@ -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
|
||||
|
@ -153,12 +154,26 @@ 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)
|
||||
|
||||
flash[:alert] = @data.css('msg').text unless response_ok?
|
||||
redirect_to info_registrar_domains_url(domain_name: params[:domain_name])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init_domain
|
||||
@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
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
class SendEInvoiceJob < Que::Job
|
||||
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 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"
|
||||
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 # #{id}.
|
||||
The error message was the following: #{error}
|
||||
This job will retry.
|
||||
TEXT
|
||||
logger.error message
|
||||
end
|
||||
|
||||
def logger
|
||||
Rails.logger
|
||||
end
|
||||
end
|
|
@ -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 }
|
||||
|
|
9
app/models/concerns/remove_hold.rb
Normal file
9
app/models/concerns/remove_hold.rb
Normal file
|
@ -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
|
|
@ -1,6 +1,7 @@
|
|||
module Depp
|
||||
class Domain
|
||||
include ActiveModel::Conversion
|
||||
include RemoveHold
|
||||
extend ActiveModel::Naming
|
||||
|
||||
attr_accessor :name, :current_user, :epp_xml
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -118,6 +118,14 @@ class Invoice < ApplicationRecord
|
|||
inv
|
||||
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
|
||||
|
|
|
@ -100,9 +100,7 @@ class Registrar < ApplicationRecord
|
|||
}
|
||||
]
|
||||
)
|
||||
|
||||
e_invoice = invoice.to_e_invoice
|
||||
e_invoice.deliver
|
||||
SendEInvoiceJob.enqueue(invoice.id)
|
||||
|
||||
invoice
|
||||
end
|
||||
|
|
|
@ -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' %>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update
|
||||
xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>example.ee</domain:name>
|
||||
<domain:rem>
|
||||
<domain:status s="clientHold"/>
|
||||
</domain:rem>
|
||||
</domain:update>
|
||||
</update>
|
||||
<clTRID>timo-1579351654</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -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'}}
|
||||
Remove Client Hold
|
||||
|
||||
%h4 Poll
|
||||
%a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'poll', epp_action: 'poll'}}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
|
@ -580,6 +581,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: <b><br>ref number<br>payment amount<br>invoice number (the first numerical value in comment field)</b>.'
|
||||
create_bank_statement: 'Create bank statement'
|
||||
create_bank_transaction: 'Create bank transaction'
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
19
db/data/20200225085234_convert_domain_delete_date.rb
Normal file
19
db/data/20200225085234_convert_domain_delete_date.rb
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
2
db/data_schema.rb
Normal file
2
db/data_schema.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
# encoding: UTF-8
|
||||
DataMigrate::Data.define(version: 20150707103801)
|
|
@ -0,0 +1,5 @@
|
|||
class AddEInvoiceSentAtToInvoice < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :invoices, :e_invoice_sent_at, :datetime
|
||||
end
|
||||
end
|
|
@ -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');
|
||||
|
||||
|
||||
|
|
0
lib/tasks/data_migrations/.keep
Normal file
0
lib/tasks/data_migrations/.keep
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
47
test/jobs/send_e_invoice_job_test.rb
Normal file
47
test/jobs/send_e_invoice_job_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
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.id)
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
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.id)
|
||||
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.id)
|
||||
end
|
||||
@invoice.reload
|
||||
|
||||
assert_not @invoice.e_invoice_sent_at.blank?
|
||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue