From ea2b64bc6975c19758502d80bff3c3932f25c750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Mon, 24 Nov 2014 11:11:54 +0200 Subject: [PATCH] Rubocop style fixes --- app/helpers/epp/contacts_helper.rb | 9 ++++----- spec/epp/contact_spec.rb | 12 ++++++------ spec/support/epp_contact_xml_helper.rb | 12 +++++------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index bcce06009..8945e6b65 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -21,7 +21,7 @@ module Epp::ContactsHelper # rubocop:disable Metrics/CyclomaticComplexity def delete_contact @contact = find_contact - handle_errors(@contact) and return unless rights? #owner? + handle_errors(@contact) and return unless rights? # owner? handle_errors(@contact) and return unless @contact handle_errors(@contact) and return unless @contact.destroy_and_clean @@ -54,15 +54,14 @@ module Epp::ContactsHelper def validate_contact_create_request @ph = params_hash['epp']['command']['create']['create'] return false unless validate_params - #xml_attrs_present?(@ph, [%w(postalInfo)]) + # xml_attrs_present?(@ph, [%w(postalInfo)]) xml_attrs_present?(@ph, [%w(postalInfo name), %w(postalInfo addr city), %w(postalInfo addr cc), %w(ident), %w(voice), %w(email)]) - - return epp_errors.empty? #unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array) + epp_errors.empty? # unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array) # (epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten! - #xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)]) + # xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)]) end ## UPDATE diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 6b8a0409d..45dc968ab 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -102,7 +102,7 @@ describe 'EPP Contact', epp: true do context 'update command' do it 'fails if request is invalid' do xml = EppXml::Contact.update - response = epp_request(xml, :xml) #epp_request('contacts/update_missing_attr.xml') + response = epp_request(xml, :xml) # epp_request('contacts/update_missing_attr.xml') expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:msg]).to eq('Required parameter missing: add, rem or chg') @@ -116,7 +116,7 @@ describe 'EPP Contact', epp: true do it 'fails with wrong authentication info' do Fabricate(:contact, code: 'sh8013', auth_info: 'password_wrong') - response = epp_request(update_contact_xml({id: { value: 'sh8013'}}), :xml, :elkdata ) #('contacts/update.xml') + response = epp_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml, :elkdata) expect(response[:msg]).to eq('Authorization error') expect(response[:result_code]).to eq('2201') @@ -131,7 +131,7 @@ describe 'EPP Contact', epp: true do code: 'sh8013', auth_info: 'password' ) - response = epp_request(update_contact_xml({id: { value: 'sh8013' }}), :xml) + response = epp_request(update_contact_xml({ id: { value: 'sh8013' } }), :xml) expect(response[:msg]).to eq('Command completed successfully') expect(Contact.first.name).to eq('John Doe Edited') @@ -226,7 +226,7 @@ describe 'EPP Contact', epp: true do context 'check command' do it 'fails if request is invalid' do - xml = EppXml::Contact.check( { uid: { value: '123asde' } } ) + xml = EppXml::Contact.check({ uid: { value: '123asde' } }) response = epp_request(xml, :xml) expect(response[:results][0][:result_code]).to eq('2003') @@ -253,7 +253,7 @@ describe 'EPP Contact', epp: true do context 'info command' do it 'fails if request invalid' do - response = epp_request(EppXml::Contact.info({ uid: { value: '123123' }}), :xml ) + response = epp_request(EppXml::Contact.info({ uid: { value: '123123' } }), :xml) expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:msg]).to eq('Required parameter missing: id') @@ -285,7 +285,7 @@ describe 'EPP Contact', epp: true do pending 'Disclosure needs to have some of the details worked out' Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR', disclosure: Fabricate(:contact_disclosure, email: false, phone: false)) - response = epp_request(info_contact_xml( id: { value: 'info-4444' } ), :xml) + response = epp_request(info_contact_xml(id: { value: 'info-4444' }), :xml) contact = response[:parsed].css('resData chkData') expect(response[:result_code]).to eq('1000') diff --git a/spec/support/epp_contact_xml_helper.rb b/spec/support/epp_contact_xml_helper.rb index 4e7c48ca3..63f407843 100644 --- a/spec/support/epp_contact_xml_helper.rb +++ b/spec/support/epp_contact_xml_helper.rb @@ -1,5 +1,5 @@ module EppContactXmlHelper - def create_contact_xml(xml_params={}) + def create_contact_xml(xml_params = {}) defaults = { postalInfo: { name: { value: 'John Doe' }, @@ -18,7 +18,7 @@ module EppContactXmlHelper EppXml::Contact.create(xml_params) end - def update_contact_xml(xml_params={}) + def update_contact_xml(xml_params = {}) defaults = { id: { value: 'asd123123er' }, authInfo: { pw: { value: 'password' } }, @@ -34,19 +34,19 @@ module EppContactXmlHelper EppXml::Contact.update(xml_params) end - def delete_contact_xml(xml_params={}) + def delete_contact_xml(xml_params = {}) defaults = { id: { value: 'sh8012' } } xml_params = defaults.deep_merge(xml_params) EppXml::Contact.delete(xml_params) end - def info_contact_xml(xml_params={}) + def info_contact_xml(xml_params = {}) defaults = { id: { value: 'sh8012' }, authInfo: { pw: { value: 'password' } } } xml_params = defaults.deep_merge(xml_params) EppXml::Contact.info(xml_params) end - def check_contact_xml(xml_params={}) + def check_contact_xml(xml_params = {}) defaults = { id: { value: 'ad123c3' } } @@ -69,10 +69,8 @@ module EppContactXmlHelper ' end - end - RSpec.configure do |c| c.include EppContactXmlHelper end