diff --git a/app/models/domain.rb b/app/models/domain.rb index 6dd477746..74cf668b7 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -63,6 +63,7 @@ class Domain < ActiveRecord::Base def detach_objects(ph, parsed_frame) detach_contacts(self.class.parse_contacts_from_frame(parsed_frame)) detach_nameservers(self.class.parse_nameservers_from_frame(parsed_frame)) + detach_statuses(self.class.parse_statuses_from_frame(parsed_frame)) errors.empty? end @@ -161,6 +162,24 @@ class Domain < ActiveRecord::Base self.nameservers.delete(to_delete) end + def detach_statuses(status_list) + to_delete = [] + status_list.each do |x| + status = domain_statuses.joins(:setting).where(settings: {value: x[:value]}) + if status.blank? + errors.add(:domain_statuses, { + obj: 'status', + val: x[:value], + msg: errors.generate_message(:domain_statuses, :not_found) + }) + else + to_delete << status + end + end + + self.domain_statuses.delete(to_delete) + end + ### RENEW ### def renew(cur_exp_date, period, unit='y') @@ -232,7 +251,8 @@ class Domain < ActiveRecord::Base '2303' => [ # Object does not exist [:owner_contact, :epp_registrant_not_found], [:domain_contacts, :not_found], - [:nameservers, :not_found] + [:nameservers, :not_found], + [:domain_statuses, :not_found] ], '2200' => [ [:auth_info, :wrong_pw] diff --git a/config/locales/en.yml b/config/locales/en.yml index 42d5e768d..642328210 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -57,6 +57,8 @@ en: out_of_range: 'Period must add up to 1, 2 or 3 years' auth_info: wrong_pw: 'Authentication error' + domain_statuses: + not_found: 'Status was not found' nameserver: attributes: hostname: diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 64f2f0d61..0ff8683e7 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -287,6 +287,9 @@ describe 'EPP Domain', epp: true do response = epp_request('domains/update_remove_objects.xml') + expect(d.domain_statuses.count).to eq(1) + expect(d.domain_statuses.first.value).to eq('clientUpdateProhibited') + rem_ns = d.nameservers.find_by(hostname: 'ns1.example.com') expect(rem_ns).to be_falsey @@ -302,6 +305,11 @@ describe 'EPP Domain', epp: true do expect(response[:results][1][:result_code]).to eq('2303') expect(response[:results][1][:msg]).to eq('Nameserver was not found') expect(response[:results][1][:value]).to eq('ns1.example.com') + + expect(response[:results][2][:result_code]).to eq('2303') + expect(response[:results][2][:msg]).to eq('Status was not found') + expect(response[:results][2][:value]).to eq('clientHold') + end end