From afc69629ef94ec0358955ff520edf49567e83a23 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Mon, 1 Sep 2014 12:10:31 +0300 Subject: [PATCH] Refactor delete.xml to builder --- doc/epp_request_examples.xml | 14 +++++++++++ spec/epp/domain_spec.rb | 4 +-- spec/epp/epp_helper_spec.rb | 37 ++++++++++++++++++++++++++++ spec/epp/requests/domains/delete.xml | 12 --------- spec/support/epp.rb | 19 ++++++++++++++ 5 files changed, 72 insertions(+), 14 deletions(-) delete mode 100644 spec/epp/requests/domains/delete.xml diff --git a/doc/epp_request_examples.xml b/doc/epp_request_examples.xml index 5321241d0..f84917611 100644 --- a/doc/epp_request_examples.xml +++ b/doc/epp_request_examples.xml @@ -103,6 +103,20 @@ + + + + + + + example.ee + + + ABC-12345 + + + diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index b73b9fe9e..d0e08033d 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -440,9 +440,9 @@ describe 'EPP Domain', epp: true do expect(d.auth_info).to eq('2BARfoo') end - it 'does not delete domain if there are relations' do + it 'deletes domain' do expect(DomainContact.count).to eq(1) - response = epp_request('domains/delete.xml') + response = epp_request(domain_delete_xml, :xml) expect(response[:result_code]).to eq('1000') expect(Domain.first).to eq(nil) diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index e4d02919f..f2dfb20e8 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -320,5 +320,42 @@ describe 'EPP Helper', epp: true do generated = Nokogiri::XML(xml).to_s.squish expect(generated).to eq(expected) end + + it 'generates valid delete xml' do + expected = Nokogiri::XML(' + + + + + example.ee + + + ABC-12345 + + + ').to_s.squish + + generated = Nokogiri::XML(domain_delete_xml).to_s.squish + expect(generated).to eq(expected) + + + expected = Nokogiri::XML(' + + + + + one.ee + + + ABC-12345 + + + ').to_s.squish + + generated = Nokogiri::XML(domain_delete_xml(name: 'one.ee')).to_s.squish + expect(generated).to eq(expected) + end end end diff --git a/spec/epp/requests/domains/delete.xml b/spec/epp/requests/domains/delete.xml deleted file mode 100644 index 868b4b24f..000000000 --- a/spec/epp/requests/domains/delete.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - example.ee - - - ABC-12345 - - diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 9ad726388..111fbc8c0 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -216,6 +216,25 @@ module Epp end end end + + def domain_delete_xml(xml_params = {}) + xml_params[:name] = xml_params[:name] || 'example.ee' + 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.delete do + xml.tag!('domain:delete', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do + if xml_params[:name] != false + xml.tag!('domain:name', xml_params[:name]) + end + end + end + xml.clTRID 'ABC-12345' + end + end + end end RSpec.configure do |c|