mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
fixed codeclimate errors
This commit is contained in:
parent
e0c47cdb35
commit
788af6cc5f
15 changed files with 32 additions and 31 deletions
|
@ -1,5 +1,5 @@
|
||||||
module Epp
|
module Epp
|
||||||
class BaseController < ActionController::Base
|
class BaseController < ApplicationController
|
||||||
class AuthorizationError < StandardError; end
|
class AuthorizationError < StandardError; end
|
||||||
skip_before_action :verify_authenticity_token
|
skip_before_action :verify_authenticity_token
|
||||||
check_authorization
|
check_authorization
|
||||||
|
|
|
@ -35,15 +35,13 @@ class Registrar
|
||||||
@depp_user.errors.add(:base, :invalid_cert)
|
@depp_user.errors.add(:base, :invalid_cert)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @depp_user.errors.none?
|
show_error and return unless @depp_user.errors.none?
|
||||||
if @api_user.active?
|
|
||||||
sign_in_and_redirect(:registrar_user, @api_user)
|
if @api_user.active?
|
||||||
else
|
sign_in_and_redirect(:registrar_user, @api_user)
|
||||||
@depp_user.errors.add(:base, :not_active)
|
|
||||||
show_error and return
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
show_error and return
|
@depp_user.errors.add(:base, :not_active)
|
||||||
|
show_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class CsyncJob < ApplicationJob
|
||||||
def process_scanner_results
|
def process_scanner_results
|
||||||
scanner_results
|
scanner_results
|
||||||
|
|
||||||
@results.keys.each do |domain|
|
@results.each_key do |domain|
|
||||||
begin
|
begin
|
||||||
next unless qualified_for_monitoring?(domain, @results[domain])
|
next unless qualified_for_monitoring?(domain, @results[domain])
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class CsyncJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_input_lines(out_file, state)
|
def create_input_lines(out_file, state)
|
||||||
@input_store[state].keys.each do |nameserver|
|
@input_store[state].each_key do |nameserver|
|
||||||
domains = @input_store[state][nameserver].join(' ')
|
domains = @input_store[state][nameserver].join(' ')
|
||||||
next unless domains.length.positive?
|
next unless domains.length.positive?
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class SendEInvoiceJob < ApplicationJob
|
class SendEInvoiceJob < ApplicationJob
|
||||||
discard_on HTTPClient::TimeoutError
|
discard_on HTTPClient::TimeoutError
|
||||||
|
|
||||||
def perform(invoice_id, payable = true)
|
def perform(invoice_id, payable: true)
|
||||||
logger.info "Started to process e-invoice for invoice_id #{invoice_id}"
|
logger.info "Started to process e-invoice for invoice_id #{invoice_id}"
|
||||||
invoice = Invoice.find_by(id: invoice_id)
|
invoice = Invoice.find_by(id: invoice_id)
|
||||||
return unless need_to_process_invoice?(invoice: invoice, payable: payable)
|
return unless need_to_process_invoice?(invoice: invoice, payable: payable)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class VerifyEmailsJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def logger
|
def logger
|
||||||
@logger ||= Logger.new(Rails.root.join('log', 'email_verification.log'))
|
@logger ||= Logger.new(Rails.root.join('log/email_verification.log'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_success(verification)
|
def log_success(verification)
|
||||||
|
|
|
@ -81,11 +81,11 @@ class Certificate < ApplicationRecord
|
||||||
csr_file.rewind
|
csr_file.rewind
|
||||||
|
|
||||||
crt_file = Tempfile.new('client_crt')
|
crt_file = Tempfile.new('client_crt')
|
||||||
_out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} \
|
_out, err, _st = Open3.capture3("openssl", "ca", "-config", ENV['openssl_config_path'],
|
||||||
-keyfile #{ENV['ca_key_path']} \
|
"-keyfile", ENV['ca_key_path'],
|
||||||
-cert #{ENV['ca_cert_path']} \
|
"-cert", ENV['ca_cert_path'],
|
||||||
-extensions usr_cert -notext -md sha256 \
|
"-extensions", "usr_cert", "-notext", "-md sha256",
|
||||||
-in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch")
|
"-in", csr_file.path, "-out", crt_file.path, "-key", ENV['ca_key_password'], "-batch")
|
||||||
|
|
||||||
if err.match?(/Data Base Updated/)
|
if err.match?(/Data Base Updated/)
|
||||||
crt_file.rewind
|
crt_file.rewind
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Contact < ApplicationRecord
|
||||||
include Contact::Archivable
|
include Contact::Archivable
|
||||||
include EmailVerifable
|
include EmailVerifable
|
||||||
|
|
||||||
belongs_to :original, class_name: name
|
belongs_to :original, class_name: 'Contact'
|
||||||
belongs_to :registrar, required: true
|
belongs_to :registrar, required: true
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
has_many :domains, through: :domain_contacts
|
has_many :domains, through: :domain_contacts
|
||||||
|
|
|
@ -241,7 +241,7 @@ module Depp
|
||||||
ident = ident_xml[:_anonymus].try(:first)
|
ident = ident_xml[:_anonymus].try(:first)
|
||||||
when :update
|
when :update
|
||||||
# detect if any ident has changed, nb! ident and self.ident is not always same
|
# detect if any ident has changed, nb! ident and self.ident is not always same
|
||||||
unless ident == self.ident && ident == ident_type && ident_country_code == ident_country_code
|
unless ident == self.ident && ident == ident_type && ident_country_code == self.ident_country_code
|
||||||
ident = ident_xml[:_anonymus].try(:first)
|
ident = ident_xml[:_anonymus].try(:first)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -343,10 +343,10 @@ class Domain < ApplicationRecord
|
||||||
# find by internationalized domain name
|
# find by internationalized domain name
|
||||||
# internet domain name => ascii or puny, but db::domains.name is unicode
|
# internet domain name => ascii or puny, but db::domains.name is unicode
|
||||||
def self.find_by_idn(name)
|
def self.find_by_idn(name)
|
||||||
domain = find_by_name name
|
domain = find_by(name: name)
|
||||||
if domain.blank? && name.include?('-')
|
if domain.blank? && name.include?('-')
|
||||||
unicode = SimpleIDN.to_unicode name # we have no index on domains.name_puny
|
unicode = SimpleIDN.to_unicode name # we have no index on domains.name_puny
|
||||||
domain = find_by_name unicode
|
domain = find_by(name: unicode)
|
||||||
end
|
end
|
||||||
domain
|
domain
|
||||||
end
|
end
|
||||||
|
|
|
@ -216,7 +216,8 @@ class Epp::Domain < Domain
|
||||||
return transfers.last if transfers.any?
|
return transfers.last if transfers.any?
|
||||||
when 'request'
|
when 'request'
|
||||||
return pending_transfer if pending_transfer
|
return pending_transfer if pending_transfer
|
||||||
return query_transfer(frame, current_user)
|
|
||||||
|
query_transfer(frame, current_user)
|
||||||
when 'approve'
|
when 'approve'
|
||||||
return approve_transfer(frame, current_user) if pending_transfer
|
return approve_transfer(frame, current_user) if pending_transfer
|
||||||
when 'reject'
|
when 'reject'
|
||||||
|
|
|
@ -17,13 +17,15 @@ class Invoice < ApplicationRecord
|
||||||
scope :all_columns, -> { select("invoices.*") }
|
scope :all_columns, -> { select("invoices.*") }
|
||||||
scope :sort_due_date_column, -> { all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
|
scope :sort_due_date_column, -> { all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN
|
||||||
(invoices.cancelled_at + interval '100 year') ELSE
|
(invoices.cancelled_at + interval '100 year') ELSE
|
||||||
invoices.due_date END AS sort_due_date") }
|
invoices.due_date END AS sort_due_date")
|
||||||
|
}
|
||||||
scope :sort_by_sort_due_date_asc, -> { sort_due_date_column.order("sort_due_date ASC") }
|
scope :sort_by_sort_due_date_asc, -> { sort_due_date_column.order("sort_due_date ASC") }
|
||||||
scope :sort_by_sort_due_date_desc, -> { sort_due_date_column.order("sort_due_date DESC") }
|
scope :sort_by_sort_due_date_desc, -> { sort_due_date_column.order("sort_due_date DESC") }
|
||||||
scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%Q{
|
scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%(
|
||||||
CASE WHEN account_activities.created_at is not null THEN account_activities.created_at
|
CASE WHEN account_activities.created_at is not null THEN account_activities.created_at
|
||||||
WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year'
|
WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year'
|
||||||
ELSE NULL END AS sort_receipt_date })}
|
ELSE NULL END AS sort_receipt_date ))
|
||||||
|
}
|
||||||
scope :sort_by_sort_receipt_date_asc, -> { sort_receipt_date_column.order("sort_receipt_date ASC") }
|
scope :sort_by_sort_receipt_date_asc, -> { sort_receipt_date_column.order("sort_receipt_date ASC") }
|
||||||
scope :sort_by_sort_receipt_date_desc, -> { sort_receipt_date_column.order("sort_receipt_date DESC") }
|
scope :sort_by_sort_receipt_date_desc, -> { sort_receipt_date_column.order("sort_receipt_date DESC") }
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Registrar < ApplicationRecord
|
||||||
.deliver_later(wait: 1.minute)
|
.deliver_later(wait: 1.minute)
|
||||||
end
|
end
|
||||||
|
|
||||||
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable)
|
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
||||||
|
|
||||||
invoice
|
invoice
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ReservedDomain < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def fill_empty_passwords
|
def fill_empty_passwords
|
||||||
regenerate_password if self.password.blank?
|
regenerate_password if password.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def regenerate_password
|
def regenerate_password
|
||||||
|
|
|
@ -82,8 +82,8 @@ module Xsd
|
||||||
end
|
end
|
||||||
|
|
||||||
def schemas_by_name
|
def schemas_by_name
|
||||||
prefixes.each_with_object({}) do |prefix, hash|
|
prefixes.index_with do |prefix|
|
||||||
hash[prefix] = xsd_schemas.select { |filename| prefix_check(prefix, filename) }.uniq.sort
|
xsd_schemas.select { |filename| prefix_check(prefix, filename) }.uniq.sort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class SendEInvoiceJobTest < ActiveJob::TestCase
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
perform_enqueued_jobs do
|
perform_enqueued_jobs do
|
||||||
SendEInvoiceJob.perform_now(@invoice.id, true)
|
SendEInvoiceJob.perform_now(@invoice.id, payable: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@invoice.reload
|
@invoice.reload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue