Add exception to EppErrors concerning settings

This commit is contained in:
Martin Lensment 2014-08-22 12:13:41 +03:00
parent 87cc7799be
commit b42357b26d
3 changed files with 16 additions and 5 deletions

View file

@ -28,7 +28,17 @@ module EppErrors
else
next unless code = find_epp_code(err)
err = {code: code, msg: err}
err[:value] = {val: send(key), obj: self.class::EPP_ATTR_MAP[key]} unless self.class.reflect_on_association(key)
# If we have setting relation, then still add the value to the error message
# If this sort of exception happens again, some other logic has to be implemented
if self.class.reflect_on_association(key) && key == :setting
err[:value] = {val: send(key).value, obj: self.class::EPP_ATTR_MAP[key]}
#if the key represents other relations, skip value
elsif !self.class.reflect_on_association(key)
err[:value] = {val: send(key), obj: self.class::EPP_ATTR_MAP[key]}
end
epp_errors << err
end
end

View file

@ -68,9 +68,7 @@ en:
taken: 'Code already exists'
domain_status:
attributes:
setting:
taken: 'Status already exists on this domain'
value:
setting_id:
taken: 'Status already exists on this domain'
attributes:
domain:
@ -81,6 +79,7 @@ en:
errors:
messages:
taken: 'Status already exists on this domain'
blank: 'is missing'
epp_domain_reserved: 'Domain name is reserved or restricted'
epp_obj_does_not_exist: 'Object does not exist'

View file

@ -271,9 +271,11 @@ describe 'EPP Domain', epp: true do
expect(d.domain_statuses.last.value).to eq('clientUpdateProhibited')
response = epp_request('domains/update_add_objects.xml')
expect(response[:results][0][:result_code]).to eq('2302')
expect(response[:results][0][:msg]).to eq('Status already exists on this domain')
expect(response[:results][0][:value]).to eq('clientHold')
expect(response[:results][1][:msg]).to eq('Status already exists on this domain')
expect(response[:results][1][:value]).to eq('clientUpdateProhibited')
expect(d.domain_statuses.count).to eq(2)
end