mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
Handle OK status automatically
This commit is contained in:
parent
8892a25947
commit
77510cc3fa
5 changed files with 19 additions and 10 deletions
|
@ -36,6 +36,7 @@ class Domain < ActiveRecord::Base
|
|||
before_create :generate_auth_info
|
||||
before_create :set_validity_dates
|
||||
after_create :attach_default_contacts
|
||||
after_save :manage_automatic_statuses
|
||||
|
||||
validates :name_dirty, domain_name: true, uniqueness: true
|
||||
validates :period, numericality: { only_integer: true }
|
||||
|
@ -201,6 +202,14 @@ class Domain < ActiveRecord::Base
|
|||
domain_contacts.reject(&:marked_for_destruction?).select { |x| x.contact_type == DomainContact::ADMIN }.count
|
||||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
if domain_statuses.empty? && valid?
|
||||
domain_statuses.create(value: DomainStatus::OK)
|
||||
else
|
||||
domain_statuses.find_by(value: DomainStatus::OK).try(:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
def convert_period_to_time(period, unit)
|
||||
return period.to_i.days if unit == 'd'
|
||||
|
|
|
@ -366,10 +366,17 @@ describe 'EPP Domain', epp: true do
|
|||
expect(response[:results][0][:value]).to eq('4')
|
||||
end
|
||||
|
||||
it 'sets ok status by default' do
|
||||
response = epp_request(domain_info_xml, :xml)
|
||||
inf_data = response[:parsed].css('resData infData')
|
||||
expect(inf_data.css('status').first[:s]).to eq('ok')
|
||||
end
|
||||
|
||||
it 'returns domain info' do
|
||||
d = Domain.first
|
||||
d.domain_statuses.create(value: DomainStatus::CLIENT_HOLD, description: 'Payment overdue.')
|
||||
d.nameservers.create(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
|
||||
d.domain_statuses.build(value: DomainStatus::CLIENT_HOLD, description: 'Payment overdue.')
|
||||
d.nameservers.build(hostname: 'ns1.example.com', ipv4: '192.168.1.1', ipv6: '1080:0:0:0:8:800:200C:417A')
|
||||
d.save
|
||||
|
||||
response = epp_request(domain_info_xml, :xml)
|
||||
expect(response[:results][0][:result_code]).to eq('1000')
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
|||
|
||||
describe Domain do
|
||||
it { should belong_to(:registrar) }
|
||||
it { should have_and_belong_to_many(:nameservers) }
|
||||
it { should have_many(:nameservers) }
|
||||
it { should belong_to(:owner_contact) }
|
||||
it { should have_many(:tech_contacts) }
|
||||
it { should have_many(:admin_contacts) }
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe NsSet do
|
||||
it { should belong_to(:registrar) }
|
||||
it { should have_and_belong_to_many(:nameservers) }
|
||||
end
|
|
@ -3,7 +3,6 @@ require 'rails_helper'
|
|||
describe Registrar do
|
||||
it { should belong_to(:country) }
|
||||
it { should have_many(:domains) }
|
||||
it { should have_many(:ns_sets) }
|
||||
it { should have_many(:epp_users) }
|
||||
it { should have_many(:users) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue