mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
Corrected tests
This commit is contained in:
parent
4bf656f425
commit
cc4d4d0e1f
16 changed files with 56 additions and 41 deletions
|
@ -4,7 +4,8 @@ module Admin
|
|||
|
||||
def index
|
||||
@q = Account.includes(:registrar).ransack(params[:q])
|
||||
@accounts = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@accounts = @result.page(params[:page])
|
||||
@accounts = @accounts.per(params[:results_per_page]) if paginate?
|
||||
|
||||
render_by_format('admin/accounts/index', 'accounts')
|
||||
|
|
|
@ -15,7 +15,8 @@ module Admin
|
|||
|
||||
normalize_search_parameters do
|
||||
@q = @auctions.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@auctions = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@auctions = @result.page(params[:page])
|
||||
end
|
||||
|
||||
@auctions = @auctions.per(params[:results_per_page_auction]) if params[:results_per_page_auction].to_i.positive?
|
||||
|
|
|
@ -26,7 +26,7 @@ module Admin
|
|||
respond_to do |format|
|
||||
format.html { render page }
|
||||
format.csv do
|
||||
raw_csv = CsvGenerator.generate_csv(@q.result(distinct: true))
|
||||
raw_csv = CsvGenerator.generate_csv(@result)
|
||||
send_data raw_csv,
|
||||
filename: "#{filename}_#{Time.zone.now.to_formatted_s(:number)}.csv",
|
||||
type: "#{Mime[:csv]}; charset=utf-8"
|
||||
|
|
|
@ -6,7 +6,8 @@ module Admin
|
|||
params[:q] ||= {}
|
||||
domains = BlockedDomain.all.order(:name)
|
||||
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@domains = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@domains = @result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
render_by_format('admin/blocked_domains/index', 'blocked_domains')
|
||||
|
|
|
@ -10,8 +10,8 @@ module Admin
|
|||
search_params = PartialSearchFormatter.format(fix_date_params)
|
||||
versions = Version::ContactVersion.includes(:item).order(created_at: :desc, id: :desc)
|
||||
@q = versions.ransack(polymorphic_association(search_params))
|
||||
|
||||
@versions = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@versions = @result.page(params[:page])
|
||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
render_by_format('admin/contact_versions/index', 'contact_history')
|
||||
|
@ -24,7 +24,7 @@ module Admin
|
|||
@versions_map = @versions.all.map(&:id)
|
||||
|
||||
# what we do is calc amount of results until needed version
|
||||
# then we cacl which page it is
|
||||
# then we calc which page it is
|
||||
if params[:page].blank?
|
||||
counter = @versions_map.index(@version.id) + 1
|
||||
page = counter / per_page
|
||||
|
|
|
@ -19,7 +19,8 @@ module Admin
|
|||
|
||||
normalize_search_parameters do
|
||||
@q = contacts.ransack(PartialSearchFormatter.format(search_params))
|
||||
@contacts = @q.result.distinct.page(params[:page])
|
||||
@result = @q.result.distinct
|
||||
@contacts = @result.page(params[:page])
|
||||
end
|
||||
|
||||
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
|
|
@ -57,7 +57,8 @@ module Admin
|
|||
|
||||
def sortable_dispute_query_for(disputes, query, closed: false)
|
||||
@q = disputes.order(:domain_name).ransack(query)
|
||||
disputes = @q.result.page(closed ? params[:closed_page] : params[:page])
|
||||
@result = @q.result
|
||||
disputes = @result.page(closed ? params[:closed_page] : params[:page])
|
||||
return disputes.per(params[:results_per_page]) if params[:results_per_page].present?
|
||||
|
||||
disputes
|
||||
|
|
|
@ -47,8 +47,8 @@ module Admin
|
|||
|
||||
versions = Version::DomainVersion.includes(:item).where(where_s).order(created_at: :desc, id: :desc)
|
||||
@q = versions.ransack(fix_date_params)
|
||||
|
||||
@versions = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@versions = @result.page(params[:page])
|
||||
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
render_by_format('admin/domain_versions/archive', 'domain_history')
|
||||
|
|
|
@ -13,7 +13,8 @@ module Admin
|
|||
|
||||
normalize_search_parameters do
|
||||
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@domains = @q.result(distinct: true).page(params[:page])
|
||||
@result = @q.result.distinct
|
||||
@domains = @result.page(params[:page])
|
||||
end
|
||||
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
|
|
@ -6,9 +6,10 @@ module Admin
|
|||
# rubocop:disable Metrics/MethodLength
|
||||
def index
|
||||
@q = ApiLog::EppLog.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@result = @q.result
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
||||
@epp_logs = @q.result
|
||||
@epp_logs = @result
|
||||
if params[:q][:created_at_gteq].present?
|
||||
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
||||
Time.parse(params[:q][:created_at_gteq]))
|
||||
|
|
|
@ -39,7 +39,8 @@ module Admin
|
|||
|
||||
@q = invoices.ransack(params[:q])
|
||||
@q.sorts = 'number desc' if @q.sorts.empty?
|
||||
@invoices = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@invoices = @result.page(params[:page])
|
||||
@invoices = @invoices.per(params[:results_per_page]) if paginate?
|
||||
|
||||
render_by_format('admin/invoices/index', 'invoices')
|
||||
|
|
|
@ -7,8 +7,8 @@ module Admin
|
|||
def index
|
||||
@q = ApiLog::ReppLog.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
||||
@repp_logs = @q.result
|
||||
@result = @q.result
|
||||
@repp_logs = @result
|
||||
if params[:q][:created_at_gteq].present?
|
||||
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
|
||||
Time.parse(params[:q][:created_at_gteq]))
|
||||
|
|
|
@ -7,7 +7,8 @@ module Admin
|
|||
params[:q] ||= {}
|
||||
domains = ReservedDomain.all.order(:name)
|
||||
@q = domains.ransack(PartialSearchFormatter.format(params[:q]))
|
||||
@domains = @q.result.page(params[:page])
|
||||
@result = @q.result
|
||||
@domains = @result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
|
||||
|
||||
render_by_format('admin/reserved_domains/index', 'reserved_domains')
|
||||
|
|
|
@ -154,30 +154,30 @@ class Domain < ApplicationRecord
|
|||
|
||||
validates :nameservers, domain_nameserver: {
|
||||
min: -> { Setting.ns_min_count },
|
||||
max: -> { Setting.ns_max_count }
|
||||
max: -> { Setting.ns_max_count },
|
||||
}
|
||||
|
||||
validates :dnskeys, object_count: {
|
||||
min: -> { Setting.dnskeys_min_count },
|
||||
max: -> { Setting.dnskeys_max_count }
|
||||
max: -> { Setting.dnskeys_max_count },
|
||||
}
|
||||
|
||||
validates :admin_domain_contacts, object_count: {
|
||||
min: -> { Setting.admin_contacts_min_count },
|
||||
max: -> { Setting.admin_contacts_max_count }
|
||||
max: -> { Setting.admin_contacts_max_count },
|
||||
}
|
||||
|
||||
validates :tech_domain_contacts, object_count: {
|
||||
min: -> { Setting.tech_contacts_min_count },
|
||||
max: -> { Setting.tech_contacts_max_count }
|
||||
max: -> { Setting.tech_contacts_max_count },
|
||||
}
|
||||
|
||||
validates :nameservers, uniqueness_multi: {
|
||||
attribute: 'hostname'
|
||||
attribute: 'hostname',
|
||||
}
|
||||
|
||||
validates :dnskeys, uniqueness_multi: {
|
||||
attribute: 'public_key'
|
||||
attribute: 'public_key',
|
||||
}
|
||||
|
||||
validate :validate_nameserver_ips
|
||||
|
@ -225,7 +225,7 @@ class Domain < ApplicationRecord
|
|||
end
|
||||
|
||||
def delegated_nameservers
|
||||
nameservers.select { |x| !x.hostname.end_with?(name) }
|
||||
nameservers.reject { |x| x.hostname.end_with?(name) }
|
||||
end
|
||||
|
||||
def extension_update_prohibited?
|
||||
|
@ -604,7 +604,8 @@ class Domain < ApplicationRecord
|
|||
|
||||
# check for deleted status
|
||||
statuses.each do |s|
|
||||
unless update.include? s
|
||||
next if update.include? s
|
||||
|
||||
case s
|
||||
when DomainStatus::PENDING_DELETE
|
||||
self.delete_date = nil
|
||||
|
@ -617,7 +618,6 @@ class Domain < ApplicationRecord
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pending_update_prohibited?
|
||||
(statuses_was & DomainStatus::UPDATE_PROHIBIT_STATES).present?
|
||||
|
@ -626,7 +626,7 @@ class Domain < ApplicationRecord
|
|||
def set_pending_update
|
||||
if pending_update_prohibited?
|
||||
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_UPDATE not allowed to set. [#{statuses}]"
|
||||
return nil
|
||||
return
|
||||
end
|
||||
statuses << DomainStatus::PENDING_UPDATE
|
||||
end
|
||||
|
@ -655,7 +655,7 @@ class Domain < ApplicationRecord
|
|||
def set_pending_delete
|
||||
if pending_delete_prohibited?
|
||||
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_DELETE not allowed to set. [#{statuses}]"
|
||||
return nil
|
||||
return
|
||||
end
|
||||
statuses << DomainStatus::PENDING_DELETE
|
||||
end
|
||||
|
@ -665,6 +665,12 @@ class Domain < ApplicationRecord
|
|||
self.outzone_at = Time.current
|
||||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
check_nameservers
|
||||
check_statuses
|
||||
check_pending_delete
|
||||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
unless self.class.nameserver_required?
|
||||
deactivate if nameservers.reject(&:marked_for_destruction?).empty?
|
||||
|
@ -814,7 +820,7 @@ class Domain < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.uses_zone?(zone)
|
||||
exists?(["name ILIKE ?", "%.#{zone.origin}"])
|
||||
exists?(['name ILIKE ?', "%.#{zone.origin}"])
|
||||
end
|
||||
|
||||
def self.swap_elements(array, indexes)
|
||||
|
|
|
@ -14,7 +14,7 @@ class Version::DomainVersion < PaperTrail::Version
|
|||
domain.registrant_name,
|
||||
domain.registrar,
|
||||
event,
|
||||
created_at.to_formatted_s(:db)
|
||||
created_at.to_formatted_s(:db),
|
||||
]
|
||||
end
|
||||
|
||||
|
|
4
test/fixtures/files/domains.csv
vendored
4
test/fixtures/files/domains.csv
vendored
|
@ -1,2 +1,2 @@
|
|||
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Contacts code,Force delete date,Force delete data
|
||||
metro.test,Jack,2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""jack-001"", ""jack-001""]",,
|
||||
Domain,Registrant,Valid to,Registrar,Created at,Statuses,Admin. contacts,Tech. contacts,Nameservers,Force delete date,Force delete data
|
||||
metro.test,"Jack, 12345678 [US org]",2010-07-05 00:00:00,Good Names,2010-07-05 07:30:00,[],"[""Jack, jack-001, 12345678 [US org]""]","[""Jack, jack-001, 12345678 [US org]""]","[""ns1.bestnames.test""]",,
|
||||
|
|
|
Loading…
Add table
Add a link
Reference in a new issue