diff --git a/app/models/concerns/epp_errors.rb b/app/models/concerns/epp_errors.rb index cb7f53dd2..2fe3dc124 100644 --- a/app/models/concerns/epp_errors.rb +++ b/app/models/concerns/epp_errors.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 6465dd977..e8c4a2411 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 0ef3e6671..9d2792475 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -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