From a9df2c82b173b44d6fdc920adaeba8352f7bd1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Fri, 29 Aug 2014 16:12:11 +0300 Subject: [PATCH] Contact#update tests to check disclosure update --- app/helpers/epp/contacts_helper.rb | 5 +++-- spec/epp/contact_spec.rb | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index fd0c9ff34..f54147731 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -7,12 +7,13 @@ module Epp::ContactsHelper end def update_contact + # FIXME: Update returns 2303 update multiple times code = params_hash['epp']['command']['update']['update'][:id] @contact = Contact.where(code: code).first if rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update)) render 'epp/contacts/update' else - contact_exists? + contact_exists?(code) handle_errors(@contact) end end @@ -67,7 +68,7 @@ module Epp::ContactsHelper xml_attrs_present?(@ph, [['id']]) end - def contact_exists? + def contact_exists?(code) return true if @contact.is_a?(Contact) epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist'), value: { obj: 'id', val: code } } diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 0de164227..98531abd4 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -133,6 +133,16 @@ describe 'EPP Contact', epp: true do expect(response[:results][1][:result_code]).to eq('2005') expect(response[:results][1][:msg]).to eq('Email is invalid') end + + it 'updates disclosure items' do + Fabricate(:contact, code: 'sh8013', auth_info: '2fooBAR', + disclosure: Fabricate(:contact_disclosure, phone:true, email:true)) + epp_request('contacts/update.xml') + + expect(Contact.last.disclosure.phone).to eq(false) + expect(Contact.last.disclosure.email).to eq(false) + expect(Contact.count).to eq(1) + end end context 'delete command' do