From 9117908bb0d6c739867a5d5b77ee0f853b36b2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Thu, 31 Jul 2014 13:36:59 +0300 Subject: [PATCH 1/2] Moved contact epp errors to i18n --- app/helpers/epp/contacts_helper.rb | 8 ++++---- config/locales/en.yml | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index 5cc0fbb3e..7320a47c6 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -33,10 +33,10 @@ module Epp::ContactsHelper @contact.destroy render '/epp/contacts/delete' rescue NoMethodError => e - epp_errors << {code: '2303', msg: "Object does not exist"} + epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') } render '/epp/error' rescue - epp_errors << {code: '2400', msg: "Command failed"} + epp_errors << {code: '2400', msg: t('errors.messages.epp_command_failed')} render '/epp/error' end end @@ -48,7 +48,7 @@ module Epp::ContactsHelper if @contacts.any? render '/epp/contacts/check' else - epp_errors << {code: '2303', msg: "Object does not exist"} + epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') } render 'epp/error' end end @@ -62,7 +62,7 @@ module Epp::ContactsHelper if @contact render '/epp/contacts/info' else - epp_errors << { code: '2303', msg: 'Object does not exist' } + epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') } render 'epp/error' end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 11d9c1113..0708db0e4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -47,3 +47,5 @@ en: messages: epp_domain_reserved: 'Domain name is reserved or restricted' epp_domain_taken: 'Domain name already exists' + epp_obj_does_not_exist: 'Object does not exist' + epp_command_failed: 'Command failed' From 62230321bb9d5e5293ff1a012b26c96caadd6e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Thu, 31 Jul 2014 13:53:52 +0300 Subject: [PATCH 2/2] Tweaked contact spec to improve coverage --- spec/epp/contact_spec.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 8eb092057..6d3ebd2eb 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -54,6 +54,13 @@ describe 'EPP Contact', epp: true do 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') + + expect(ids[0].attributes['avail'].text).to eq('0') + expect(ids[1].attributes['avail'].text).to eq('1') + + expect(ids[0].text).to eq('sh8913') + expect(ids[1].text).to eq('sh8914') end @@ -64,15 +71,15 @@ describe 'EPP Contact', epp: true do end it 'returns info about contact' do - contact = Fabricate(:contact, :name => "Johnny Awesome") + Fabricate(:contact, :name => "Johnny Awesome") Fabricate(:address) response = epp_request('contacts/info.xml') - contact_res = response[:parsed].css('resData chkData') + contact = response[:parsed].css('resData chkData') expect(response[:result_code]).to eq('1000') expect(response[:msg]).to eq('Command completed successfully') - expect(contact_res.css('name').first.text).to eq('Johnny Awesome') + expect(contact.css('name').first.text).to eq('Johnny Awesome') end end