require 'rails_helper'
RSpec.describe 'EPP domain:create' do
subject(:response_xml) { Nokogiri::XML(response.body) }
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
subject(:response_description) { response_xml.css('result msg').text }
before :example do
travel_to Time.zone.parse('05.07.2010')
registrar = create(:registrar)
user = create(:api_user_epp, registrar: registrar)
create(:account, registrar: registrar, balance: 1.0)
create(:contact, code: 'test')
create(:pricelist,
category: 'com',
duration: '1year',
price: 1.to_money,
operation_category: 'create',
valid_from: Time.zone.parse('05.07.2010'),
valid_to: Time.zone.parse('05.07.2010')
)
sign_in_to_epp_area(user: user)
end
context 'when nameserver is required' do
before :example do
allow(Domain).to receive(:nameserver_required?).and_return(true)
Setting.ns_min_count = 1
end
context 'when minimum nameserver count requirement is satisfied' do
let(:request_xml) { <<-XML
test.com
1
ns.test.com
192.168.1.1
test
test
test
#{Base64.encode64('a' * 5000)}
XML
}
it 'returns epp code of 1000' do
post '/epp/command/create', frame: request_xml
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})"
end
end
context 'when nameservers are absent' do
let(:request_xml) { <<-XML
test.com
1
test
test
test
#{Base64.encode64('a' * 5000)}
XML
}
it 'returns epp code of 2003' do
post '/epp/command/create', frame: request_xml
expect(response_code).to eq('2003')
end
end
end
end