mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Add owner to technical and admin contact when no other contacts are specified
This commit is contained in:
parent
62b3ff6fc7
commit
3c3a8bfb47
3 changed files with 31 additions and 5 deletions
|
@ -11,8 +11,9 @@ class Contact < ActiveRecord::Base
|
||||||
validate :ident_must_be_valid
|
validate :ident_must_be_valid
|
||||||
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
||||||
|
|
||||||
|
IDENT_TYPE_ICO = 'ico'
|
||||||
IDENT_TYPES = [
|
IDENT_TYPES = [
|
||||||
"ico", #Company registry code (or similar)
|
IDENT_TYPE_ICO, #Company registry code (or similar)
|
||||||
"op", #Estonian ID
|
"op", #Estonian ID
|
||||||
"passport", #Passport number
|
"passport", #Passport number
|
||||||
"birthday" #Birthday date
|
"birthday" #Birthday date
|
||||||
|
@ -30,6 +31,14 @@ class Contact < ActiveRecord::Base
|
||||||
errors.add(:ident, 'bad format') unless code.valid?
|
errors.add(:ident, 'bad format') unless code.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def juridical?
|
||||||
|
ident == IDENT_TYPE_ICO
|
||||||
|
end
|
||||||
|
|
||||||
|
def citizen?
|
||||||
|
ident != IDENT_TYPE_ICO
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def check_availability(codes)
|
def check_availability(codes)
|
||||||
codes = [codes] if codes.is_a?(String)
|
codes = [codes] if codes.is_a?(String)
|
||||||
|
|
|
@ -36,12 +36,23 @@ class Domain < ActiveRecord::Base
|
||||||
def attach_contacts(contacts)
|
def attach_contacts(contacts)
|
||||||
contacts.each do |k, v|
|
contacts.each do |k, v|
|
||||||
v.each do |x|
|
v.each do |x|
|
||||||
domain_contacts.create(
|
attach_contact(k, Contact.find_by(code: x[:contact]))
|
||||||
contact: Contact.find_by(code: x[:contact]),
|
|
||||||
contact_type: k
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if owner_contact.citizen?
|
||||||
|
attach_contact(Contact::CONTACT_TYPE_TECH, owner_contact) if tech_contacts.empty?
|
||||||
|
attach_contact(Contact::CONTACT_TYPE_ADMIN, owner_contact) if admin_contacts.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def attach_contact(type, contact)
|
||||||
|
domain_contacts.create(
|
||||||
|
contact: contact,
|
||||||
|
contact_type: type
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
|
@ -14,7 +14,13 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
expect(response[:clTRID]).to eq('ABC-12345')
|
||||||
|
|
||||||
expect(Domain.first.registrar.name).to eq('Zone Media OÜ')
|
expect(Domain.first.registrar.name).to eq('Zone Media OÜ')
|
||||||
|
expect(Domain.first.tech_contacts.count).to eq 1
|
||||||
|
expect(Domain.first.admin_contacts.count).to eq 1
|
||||||
|
|
||||||
|
tech_contact = Domain.first.tech_contacts.first
|
||||||
|
expect(tech_contact.code).to eq('jd1234')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create duplicate domain' do
|
it 'does not create duplicate domain' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue