Contact#update tests to check disclosure update

This commit is contained in:
Andres Keskküla 2014-08-29 16:12:11 +03:00
parent 0e655bf306
commit a9df2c82b1
2 changed files with 13 additions and 2 deletions

View file

@ -7,12 +7,13 @@ module Epp::ContactsHelper
end end
def update_contact def update_contact
# FIXME: Update returns 2303 update multiple times
code = params_hash['epp']['command']['update']['update'][:id] code = params_hash['epp']['command']['update']['update'][:id]
@contact = Contact.where(code: code).first @contact = Contact.where(code: code).first
if rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update)) if rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update))
render 'epp/contacts/update' render 'epp/contacts/update'
else else
contact_exists? contact_exists?(code)
handle_errors(@contact) handle_errors(@contact)
end end
end end
@ -67,7 +68,7 @@ module Epp::ContactsHelper
xml_attrs_present?(@ph, [['id']]) xml_attrs_present?(@ph, [['id']])
end end
def contact_exists? def contact_exists?(code)
return true if @contact.is_a?(Contact) return true if @contact.is_a?(Contact)
epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist'), epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist'),
value: { obj: 'id', val: code } } value: { obj: 'id', val: code } }

View file

@ -133,6 +133,16 @@ describe 'EPP Contact', epp: true do
expect(response[:results][1][:result_code]).to eq('2005') expect(response[:results][1][:result_code]).to eq('2005')
expect(response[:results][1][:msg]).to eq('Email is invalid') expect(response[:results][1][:msg]).to eq('Email is invalid')
end 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 end
context 'delete command' do context 'delete command' do