Domain updating - adding contacts and nameservers

This commit is contained in:
Martin Lensment 2014-08-19 15:38:19 +03:00
parent 32fc26b5a4
commit 290182b7d1
3 changed files with 14 additions and 2 deletions

View file

@ -38,6 +38,8 @@ module Epp::DomainsHelper
@domain = find_domain @domain = find_domain
handle_errors(@domain) and return unless @domain handle_errors(@domain) and return unless @domain
handle_errors(@domain) and return unless @domain.attach_objects(@ph, parsed_frame.css('add'))
handle_errors(@domain) and return unless @domain.save
render '/epp/domains/success' render '/epp/domains/success'
end end

View file

@ -54,7 +54,7 @@ class Domain < ActiveRecord::Base
### CREATE ### ### CREATE ###
def attach_objects(ph, parsed_frame) def attach_objects(ph, parsed_frame)
attach_owner_contact(ph[:registrant]) attach_owner_contact(ph[:registrant]) if ph[:registrant]
attach_contacts(self.class.parse_contacts_from_frame(parsed_frame)) attach_contacts(self.class.parse_contacts_from_frame(parsed_frame))
attach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame)) attach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame))

View file

@ -244,13 +244,23 @@ describe 'EPP Domain', epp: true do
expect(response[:results][0][:msg]).to eq('Domain not found') expect(response[:results][0][:msg]).to eq('Domain not found')
end end
it 'updates domain', pending: true do it 'updates domain' do
response = epp_request('domains/update.xml')
expect(response[:results][0][:result_code]).to eq('2303')
expect(response[:results][0][:msg]).to eq('Contact was not found')
Fabricate(:contact, code: 'mak21')
response = epp_request('domains/update.xml') response = epp_request('domains/update.xml')
expect(response[:results][0][:result_code]).to eq('1000') expect(response[:results][0][:result_code]).to eq('1000')
d = Domain.first d = Domain.first
new_ns = d.nameservers.find_by(hostname: 'ns2.example.com') new_ns = d.nameservers.find_by(hostname: 'ns2.example.com')
expect(new_ns).to be_truthy expect(new_ns).to be_truthy
new_contact = d.tech_contacts.find_by(code: 'mak21')
expect(new_contact).to be_truthy
end end
end end