Rubocop style fixes

This commit is contained in:
Andres Keskküla 2014-11-24 11:11:54 +02:00
parent b8584de4d6
commit ea2b64bc69
3 changed files with 15 additions and 18 deletions

View file

@ -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

View file

@ -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')

View file

@ -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
</command>
</epp>'
end
end
RSpec.configure do |c|
c.include EppContactXmlHelper
end