From f2d45f4317e28abe821a24bf7f51cdd2a7f4d768 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 31 Jul 2014 12:55:21 +0300 Subject: [PATCH] Attach owner to technical --- app/models/contact.rb | 4 ++-- app/models/domain.rb | 3 ++- spec/epp/domain_spec.rb | 20 +++++++++++++++++ .../domains/create_wo_tech_contact.xml | 22 +++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 spec/epp/requests/domains/create_wo_tech_contact.xml diff --git a/app/models/contact.rb b/app/models/contact.rb index af100e0c0..b8d7b184c 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -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 diff --git a/app/models/domain.rb b/app/models/domain.rb index 439136ca0..f9dbcdb50 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -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 diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 506aef2a5..6e54b616e 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -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') diff --git a/spec/epp/requests/domains/create_wo_tech_contact.xml b/spec/epp/requests/domains/create_wo_tech_contact.xml new file mode 100644 index 000000000..d5b291ff2 --- /dev/null +++ b/spec/epp/requests/domains/create_wo_tech_contact.xml @@ -0,0 +1,22 @@ + + + + + + example.ee + 1 + + ns1.example.net + ns2.example.net + + jd1234 + sh8013 + + 2fooBAR + + + + ABC-12345 + +