From 15d267a07d029f557dc3c10501e090303168da68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 13 Aug 2014 14:29:22 +0300 Subject: [PATCH 1/4] Test for address's multiple streets --- app/views/epp/contacts/info.xml.builder | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 212879473..0bd13fc83 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -9,8 +9,12 @@ xml.epp_head do xml.tag!('contact:name', @contact.name) xml.tag!('contact:org', @contact.org_name) xml.tag!('contact:addr') do - xml.tag!('contact:street', @contact.address.street) - xml.tag!('contact:street', @contact.address.city) + @contact.address do |address| + xml.tag!('contact:street', address.street) if address.street + xml.tag!('contact:street', address.street2) if address.street2 + xml.tag!('contact:street', address.street3) if address.street3 + xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil? + end end xml.tag!('contact:voice', @contact.phone) xml.tag!('contact:fax', @contact.fax) From c4e577f437d61324ef57ab746a4ea915cb822cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 13 Aug 2014 14:46:47 +0300 Subject: [PATCH 2/4] Address fabricator fix --- spec/fabricators/address_fabricator.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/fabricators/address_fabricator.rb b/spec/fabricators/address_fabricator.rb index ef760f331..6018f18b2 100644 --- a/spec/fabricators/address_fabricator.rb +++ b/spec/fabricators/address_fabricator.rb @@ -1,6 +1,6 @@ Fabricator(:address) do - city Faker::Address.city - street Faker::Address.street_name - street Faker::Address.street_name - zip Faker::Address.zip + city Faker::Address.city + street Faker::Address.street_name + street2 Faker::Address.street_name + zip Faker::Address.zip end From ca7779fb4c77bd8509a00439ced417bfff8a4301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 13 Aug 2014 15:29:52 +0300 Subject: [PATCH 3/4] Refactored contact_check specs onto xml builder --- spec/epp/contact_spec.rb | 6 ++++-- spec/support/epp.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 6e1f03676..05557f9ce 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -34,7 +34,7 @@ describe 'EPP Contact', epp: true do end it "doesn't check contact if request is invalid" do - response = epp_request('contacts/delete_missing_attr.xml') + response = epp_request(contact_check_xml( ids: [ false ] ), :xml) expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:msg]).to eq('Required parameter missing: id') @@ -123,7 +123,9 @@ describe 'EPP Contact', epp: true do it 'checks contacts' do Fabricate(:contact, code: 'check-1234') - response = epp_request('contacts/check.xml') + response = epp_request(contact_check_xml( ids: [{ id: 'check-1234'}, { id: 'check-4321' }] ), :xml) + + #response = epp_request('contacts/check.xml') expect(response[:result_code]).to eq('1000') expect(response[:msg]).to eq('Command completed successfully') ids = response[:parsed].css('resData chkData id') diff --git a/spec/support/epp.rb b/spec/support/epp.rb index e2f27225f..4a7fffd66 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -88,6 +88,33 @@ module Epp end end end + + #contact builders + + def contact_check_xml(xml_params={}) + + xml_params[:ids] = xml_params[:ids] || [ { id: 'check-1234' }, { id: 'check-4321' } ] + + xml = Builder::XmlMarkup.new + + xml.instruct!(:xml, standalone: 'no') + xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do + xml.command do + xml.check do + xml.tag!('contact:check', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do + unless xml_params[:ids] == [false] + xml_params[:ids].each do |x| + xml.tag!('contact:id', x[:id]) + end + end + end + end + xml.clTRID 'ABC-12345' + end + end + end + + end RSpec.configure do |c| From e7ec64f7f7fbe7f3c811e0a720d7b6c9f15e7347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Wed, 13 Aug 2014 15:33:26 +0300 Subject: [PATCH 4/4] Moved contact xml builder into seperate file --- spec/support/epp.rb | 26 --------------------- spec/support/epp_contact_xml_builder.rb | 31 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 spec/support/epp_contact_xml_builder.rb diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 4a7fffd66..d33cfa400 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -89,32 +89,6 @@ module Epp end end - #contact builders - - def contact_check_xml(xml_params={}) - - xml_params[:ids] = xml_params[:ids] || [ { id: 'check-1234' }, { id: 'check-4321' } ] - - xml = Builder::XmlMarkup.new - - xml.instruct!(:xml, standalone: 'no') - xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do - xml.command do - xml.check do - xml.tag!('contact:check', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do - unless xml_params[:ids] == [false] - xml_params[:ids].each do |x| - xml.tag!('contact:id', x[:id]) - end - end - end - end - xml.clTRID 'ABC-12345' - end - end - end - - end RSpec.configure do |c| diff --git a/spec/support/epp_contact_xml_builder.rb b/spec/support/epp_contact_xml_builder.rb new file mode 100644 index 000000000..c1f71e14e --- /dev/null +++ b/spec/support/epp_contact_xml_builder.rb @@ -0,0 +1,31 @@ +module EppContactXmlBuilder + + def contact_check_xml(xml_params={}) + + xml_params[:ids] = xml_params[:ids] || [ { id: 'check-1234' }, { id: 'check-4321' } ] + + xml = Builder::XmlMarkup.new + + xml.instruct!(:xml, standalone: 'no') + xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0') do + xml.command do + xml.check do + xml.tag!('contact:check', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do + unless xml_params[:ids] == [false] + xml_params[:ids].each do |x| + xml.tag!('contact:id', x[:id]) + end + end + end + end + xml.clTRID 'ABC-12345' + end + end + end + + +end + +RSpec.configure do |c| + c.include EppContactXmlBuilder +end