From a70273a3b95f1797089e1ea4863083bc3523ca83 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 28 Jul 2015 14:06:50 +0300 Subject: [PATCH] Change blocked domain error message #2564 --- app/models/epp/domain.rb | 5 ++++- app/validators/domain_name_validator.rb | 2 +- config/locales/en.yml | 2 +- spec/epp/domain_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c36912d6b..cd2a6bf82 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -28,7 +28,7 @@ class Epp::Domain < Domain after_destroy :unlink_contacts def unlink_contacts - contacts.each do |c| + contacts.each do |c| c.domains_present = false c.save(validate: false) end @@ -104,6 +104,9 @@ class Epp::Domain < Domain [:base, :key_data_not_allowed], [:period, :not_a_number], [:period, :not_an_integer] + ], + '2308' => [ + [:base, :domain_name_blocked, { value: { obj: 'name', val: name_dirty } }] ] } end diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index 79fec0291..471565c30 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -3,7 +3,7 @@ class DomainNameValidator < ActiveModel::EachValidator if !self.class.validate_format(value) record.errors[attribute] << (options[:message] || record.errors.generate_message(attribute, :invalid)) elsif !self.class.validate_blocked(value) - record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :blocked))) + record.errors.add(:base, :domain_name_blocked) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 636b942e2..2051e1e82 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -65,10 +65,10 @@ en: key_data_not_allowed: 'keyData object is not allowed' required_parameter_missing_reserved: 'Required parameter missing; reserved>pw element required for reserved domains' invalid_auth_information_reserved: 'Invalid authorization information; invalid reserved>pw value' + domain_name_blocked: 'Data management policy violation: Domain name is blocked [name]' name_dirty: invalid: 'Domain name is invalid' reserved: 'Domain name is reserved' - blocked: 'Domain name is blocked' taken: 'Domain name already exists' puny_label: too_long: 'Domain name is too long (maximum is 63 characters)' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 0f5e4aff4..b0c7535fc 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -272,8 +272,8 @@ describe 'EPP Domain', epp: true do xml = domain_create_xml(name: { value: 'ftp.ee' }) response = epp_plain_request(xml) - response[:msg].should == 'Domain name is blocked [name_dirty]' - response[:result_code].should == '2302' + response[:msg].should == 'Data management policy violation: Domain name is blocked [name]' + response[:result_code].should == '2308' response[:results][0][:value].should == 'ftp.ee' response[:clTRID].should == 'ABC-12345' end