mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
Test fixes #2565
This commit is contained in:
parent
647d074b8b
commit
b6dd532171
7 changed files with 18 additions and 13 deletions
|
@ -266,7 +266,7 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def reserved_pw
|
||||
ReservedDomain.select("names -> '#{name}' AS pw").first.pw
|
||||
ReservedDomain.pw_for(name)
|
||||
end
|
||||
|
||||
def pending_transfer
|
||||
|
@ -474,7 +474,6 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
# rubocop:disable Lint/Loop
|
||||
def generate_auth_info
|
||||
return if auth_info.present?
|
||||
begin
|
||||
self.auth_info = SecureRandom.hex
|
||||
end while self.class.exists?(auth_info: auth_info)
|
||||
|
|
|
@ -745,7 +745,7 @@ class Epp::Domain < Domain
|
|||
next
|
||||
end
|
||||
|
||||
unless DomainNameValidator.validate_reservation(x)
|
||||
if ReservedDomain.pw_for(x).present?
|
||||
res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') }
|
||||
next
|
||||
end
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
class ReservedDomain < ActiveRecord::Base
|
||||
include Versions # version/reserved_domain_version.rb
|
||||
|
||||
class << self
|
||||
def pw_for(domain_name)
|
||||
select("names -> '#{domain_name}' AS pw").first.try(:pw)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,10 +42,10 @@ class DomainNameValidator < ActiveModel::EachValidator
|
|||
BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count == 0
|
||||
end
|
||||
|
||||
def validate_reservation(record, value)
|
||||
return true unless value
|
||||
return true if record.reserved_pw == record.auth_info
|
||||
!ReservedDomain.exists?(name: value.mb_chars.downcase.strip)
|
||||
end
|
||||
# def validate_reservation(record, value)
|
||||
# return true unless value
|
||||
# return true if record.reserved_pw == record.auth_info
|
||||
# !ReservedDomain.exists?(name: value.mb_chars.downcase.strip)
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue