mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
added dedicated registrant model
This commit is contained in:
parent
2ed9672eb5
commit
321e28b8c7
10 changed files with 40 additions and 14 deletions
|
@ -7,7 +7,7 @@ class Domain < ActiveRecord::Base
|
|||
paginates_per 10 # just for showoff
|
||||
|
||||
belongs_to :registrar
|
||||
belongs_to :registrant, class_name: 'Contact'
|
||||
belongs_to :registrant
|
||||
|
||||
has_many :domain_contacts, dependent: :destroy
|
||||
has_many :admin_domain_contacts
|
||||
|
|
|
@ -72,8 +72,9 @@ class Epp::Domain < Domain
|
|||
|
||||
def attach_default_contacts
|
||||
return if registrant.blank?
|
||||
tech_contacts << registrant if tech_domain_contacts.blank?
|
||||
admin_contacts << registrant if admin_domain_contacts.blank? && registrant.priv?
|
||||
regt = Registrant.find(registrant.id) # temp for bullet
|
||||
tech_contacts << regt if tech_domain_contacts.blank?
|
||||
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
|
@ -84,10 +85,9 @@ class Epp::Domain < Domain
|
|||
|
||||
code = frame.css('registrant').first.try(:text)
|
||||
if code.present?
|
||||
oc = Epp::Contact.find_by_epp_code(code).try(:id)
|
||||
|
||||
if oc
|
||||
at[:registrant_id] = oc
|
||||
regt = Registrant.find_by(code: code)
|
||||
if regt
|
||||
at[:registrant_id] = regt.id
|
||||
else
|
||||
add_epp_error('2303', 'registrant', code, [:registrant, :not_found])
|
||||
end
|
||||
|
|
6
app/models/registrant.rb
Normal file
6
app/models/registrant.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class Registrant < Contact
|
||||
# epp_code_map is used during epp domain create
|
||||
def epp_code_map
|
||||
{}
|
||||
end
|
||||
end
|
|
@ -124,6 +124,8 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :registrants, controller: 'contacts'
|
||||
|
||||
resources :contacts do
|
||||
collection do
|
||||
get 'search'
|
||||
|
|
|
@ -715,7 +715,7 @@ describe 'EPP Contact', epp: true do
|
|||
end
|
||||
|
||||
it 'fails if contact has associated domain' do
|
||||
@domain = Fabricate(:domain, registrar: @registrar1, registrant: @contact)
|
||||
@domain = Fabricate(:domain, registrar: @registrar1, registrant: Registrant.find(@contact.id))
|
||||
@domain.registrant.present?.should == true
|
||||
|
||||
response = delete_request
|
||||
|
|
|
@ -657,8 +657,8 @@ describe 'EPP Domain', epp: true do
|
|||
})
|
||||
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:result_code].should == '1000'
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
response[:result_code].should == '1000'
|
||||
response[:clTRID].should == 'ABC-12345'
|
||||
|
||||
Domain.last.tech_contacts.count.should == 1
|
||||
|
|
|
@ -3,11 +3,11 @@ Fabricator(:domain) do
|
|||
valid_to Date.new(2014, 8, 7)
|
||||
period 1
|
||||
period_unit 'y'
|
||||
registrant(fabricator: :contact)
|
||||
registrant(fabricator: :registrant)
|
||||
nameservers(count: 3)
|
||||
admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) }
|
||||
tech_domain_contacts(count: 1) { Fabricate(:tech_domain_contact) }
|
||||
registrar
|
||||
registrar { Registrar.find_by_code('FIXED') }
|
||||
auth_info '98oiewslkfkd'
|
||||
end
|
||||
|
||||
|
|
18
spec/fabricators/registrant_fabricator.rb
Normal file
18
spec/fabricators/registrant_fabricator.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
Fabricator(:registrant) do
|
||||
registrar { Registrar.find_by_code('FIXED') }
|
||||
code { sequence(:code) { |i| "REGISTRANT#{Faker::Number.number(8)}#{i}" } }
|
||||
auth_info 'password'
|
||||
name { sequence(:name) { |i| "REGISTRANT #{Faker::Name.name}#{i}" } }
|
||||
phone '+372.12345678'
|
||||
email Faker::Internet.email
|
||||
street 'Short street 11'
|
||||
city 'Tallinn'
|
||||
zip '11111'
|
||||
country_code 'EE'
|
||||
ident '37605030299'
|
||||
ident_type 'priv'
|
||||
ident_country_code 'EE'
|
||||
# rubocop: disable Style/SymbolProc
|
||||
after_validation { |c| c.disable_generate_auth_info! }
|
||||
# rubocop: enamble Style/SymbolProc
|
||||
end
|
|
@ -318,13 +318,13 @@ describe Contact, '.destroy_orphans' do
|
|||
end
|
||||
|
||||
it 'should find one orphan' do
|
||||
Fabricate(:domain, registrant: @contact_1)
|
||||
Fabricate(:domain, registrant: Registrant.find(@contact_1.id))
|
||||
Contact.find_orphans.count.should == 1
|
||||
Contact.find_orphans.last.should == @contact_2
|
||||
end
|
||||
|
||||
it 'should find no orphans' do
|
||||
Fabricate(:domain, registrant: @contact_1, admin_contacts: [@contact_2])
|
||||
Fabricate(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2])
|
||||
cc = Contact.count
|
||||
Contact.find_orphans.count.should == 0
|
||||
Contact.destroy_orphans
|
||||
|
|
|
@ -65,7 +65,7 @@ describe WhoisRecord do
|
|||
name: 'First Registrar Ltd',
|
||||
created_at: Time.zone.parse('1995.01.01'),
|
||||
updated_at: Time.zone.parse('1996.01.01'))
|
||||
@domain.registrant = Fabricate(:contact,
|
||||
@domain.registrant = Fabricate(:registrant,
|
||||
name: 'Jarren Jakubowski0',
|
||||
created_at: Time.zone.parse('2005.01.01'))
|
||||
@domain.admin_contacts = [Fabricate(:contact,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue