From 6be202ad16f5d615125fa3abd7b1ede93a1464c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Thu, 7 Aug 2014 16:38:34 +0300 Subject: [PATCH 1/2] Update contact now userstamps on success --- app/helpers/epp/contacts_helper.rb | 1 + spec/epp/contact_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index f365516a3..be4655c92 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -12,6 +12,7 @@ module Epp::ContactsHelper def update_contact code = params_hash['epp']['command']['update']['update'][:id] @contact = Contact.where(code: code).first + stamp @contact if @contact.update_attributes(contact_and_address_attributes.delete_if { |k, v| v.nil? }) render 'epp/contacts/update' else diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 849fba03a..8eb8dd7d8 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -29,6 +29,16 @@ describe 'EPP Contact', epp: true do expect(Contact.count).to eq(1) end + it 'stamps updated_by succesfully' do + Fabricate(:contact, code: 'sh8013') + + expect(Contact.first.updated_by_id).to be nil + + response = epp_request('contacts/update.xml') + + expect(Contact.first.updated_by_id).to be 1 + end + #TODO tests for missing/invalid/etc ident it 'deletes contact' do From 862b784761651b1615865be3bb5349c08a4ae5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Thu, 7 Aug 2014 17:24:57 +0300 Subject: [PATCH 2/2] Removed redundant begin clause --- app/helpers/epp/contacts_helper.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index be4655c92..b1121ff4c 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -23,17 +23,15 @@ module Epp::ContactsHelper def delete_contact ph = params_hash['epp']['command']['delete']['delete'] - begin - @contact = Contact.where(code: ph[:id]).first - @contact.destroy - render '/epp/contacts/delete' - rescue NoMethodError => e - epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') } - render '/epp/error' - rescue - epp_errors << {code: '2400', msg: t('errors.messages.epp_command_failed')} - render '/epp/error' - end + @contact = Contact.where(code: ph[:id]).first + @contact.destroy + render '/epp/contacts/delete' + rescue NoMethodError => e + epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') } + render '/epp/error' + rescue + epp_errors << {code: '2400', msg: t('errors.messages.epp_command_failed')} + render '/epp/error' end def check_contact