Attach owner to technical

This commit is contained in:
Martin Lensment 2014-07-31 12:55:21 +03:00
parent 3c3a8bfb47
commit f2d45f4317
4 changed files with 46 additions and 3 deletions

View file

@ -32,11 +32,11 @@ class Contact < ActiveRecord::Base
end
def juridical?
ident == IDENT_TYPE_ICO
ident_type == IDENT_TYPE_ICO
end
def citizen?
ident != IDENT_TYPE_ICO
ident_type != IDENT_TYPE_ICO
end
class << self

View file

@ -40,8 +40,9 @@ class Domain < ActiveRecord::Base
end
end
attach_contact(Contact::CONTACT_TYPE_TECH, owner_contact) if tech_contacts.empty?
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

View file

@ -55,6 +55,26 @@ describe 'EPP Domain', epp: true do
end
end
context 'with juridical persion as an owner' do
before(:each) { Fabricate(:contact, code: 'jd1234', ident_type: 'ico')}
it 'creates a domain with contacts' do
Fabricate(:contact, code: 'sh8013')
Fabricate(:contact, code: 'sh801333')
response = epp_request('domains/create_wo_tech_contact.xml')
expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully')
expect(response[:clTRID]).to eq('ABC-12345')
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 'checks a domain' do
response = epp_request('domains/check.xml')
expect(response[:result_code]).to eq('1000')

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.ee</domain:name>
<domain:period unit="y">1</domain:period>
<domain:ns>
<domain:hostObj>ns1.example.net</domain:hostObj>
<domain:hostObj>ns2.example.net</domain:hostObj>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<clTRID>ABC-12345</clTRID>
</command>
</epp>