mirror of
https://github.com/internetee/registry.git
synced 2025-05-21 19:59:38 +02:00
Detaching domain statuses
This commit is contained in:
parent
ac29ab9014
commit
3c79ca33b8
3 changed files with 31 additions and 1 deletions
|
@ -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]
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue