mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Add domain delete period method #2622
This commit is contained in:
parent
249262e224
commit
21829faf38
3 changed files with 52 additions and 11 deletions
|
@ -147,7 +147,7 @@ class Domain < ActiveRecord::Base
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def expire_domains
|
def start_expire_period
|
||||||
Domain.where('valid_to <= ?', Time.zone.now).each do |x|
|
Domain.where('valid_to <= ?', Time.zone.now).each do |x|
|
||||||
x.domain_statuses.create(value: DomainStatus::EXPIRED) if x.expirable?
|
x.domain_statuses.create(value: DomainStatus::EXPIRED) if x.expirable?
|
||||||
end
|
end
|
||||||
|
@ -158,6 +158,12 @@ class Domain < ActiveRecord::Base
|
||||||
x.domain_statuses.create(value: DomainStatus::SERVER_HOLD) if x.server_holdable?
|
x.domain_statuses.create(value: DomainStatus::SERVER_HOLD) if x.server_holdable?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def start_delete_period
|
||||||
|
Domain.where('delete_at <= ?', Time.zone.now).each do |x|
|
||||||
|
x.domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if x.deletable?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
|
@ -202,6 +208,13 @@ class Domain < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deletable?
|
||||||
|
return false if delete_at > Time.zone.now
|
||||||
|
return false if domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).any?
|
||||||
|
return false if domain_statuses.where(value: DomainStatus::SERVER_DELETE_PROHIBITED).any?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def pending_update?
|
def pending_update?
|
||||||
(domain_statuses.pluck(:value) & %W(
|
(domain_statuses.pluck(:value) & %W(
|
||||||
#{DomainStatus::PENDING_UPDATE}
|
#{DomainStatus::PENDING_UPDATE}
|
||||||
|
@ -340,13 +353,15 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def set_validity_dates
|
def set_validity_dates
|
||||||
self.registered_at = Time.zone.now
|
self.registered_at = Time.zone.now
|
||||||
self.valid_from = Time.zone.now.to_date
|
self.valid_from = Time.zone.now
|
||||||
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||||
self.outzone_at = self.valid_to + Setting.expire_warning_period.days
|
self.outzone_at = valid_to + Setting.expire_warning_period.days
|
||||||
self.delete_at = self.outzone_at + Setting.redemption_grace_period.days
|
self.delete_at = outzone_at + Setting.redemption_grace_period.days
|
||||||
end
|
end
|
||||||
|
|
||||||
def manage_automatic_statuses
|
def manage_automatic_statuses
|
||||||
|
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if deletable?
|
||||||
|
|
||||||
if domain_statuses.empty? && valid?
|
if domain_statuses.empty? && valid?
|
||||||
domain_statuses.create(value: DomainStatus::OK)
|
domain_statuses.create(value: DomainStatus::OK)
|
||||||
elsif domain_statuses.length > 1 || !valid?
|
elsif domain_statuses.length > 1 || !valid?
|
||||||
|
|
|
@ -317,7 +317,7 @@ describe 'EPP Domain', epp: true do
|
||||||
response = epp_plain_request(xml)
|
response = epp_plain_request(xml)
|
||||||
response[:msg].should == 'Command completed successfully'
|
response[:msg].should == 'Command completed successfully'
|
||||||
response[:result_code].should == '1000'
|
response[:result_code].should == '1000'
|
||||||
Domain.first.valid_to.should == 1.year.since.to_date
|
Domain.first.valid_to.should be_within(5).of(1.year.since)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a domain with invalid period' do
|
it 'does not create a domain with invalid period' do
|
||||||
|
|
|
@ -56,10 +56,10 @@ describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have correct validity dates' do
|
it 'should have correct validity dates' do
|
||||||
valid_to = Time.zone.now.beginning_of_day + 1.year
|
valid_to = Time.zone.now + 1.year
|
||||||
@domain.valid_to.should == valid_to
|
@domain.valid_to.should be_within(5).of(valid_to)
|
||||||
@domain.outzone_at.should == valid_to + Setting.expire_warning_period.days
|
@domain.outzone_at.should be_within(5).of(valid_to + Setting.expire_warning_period.days)
|
||||||
@domain.delete_at.should == valid_to + Setting.expire_warning_period.days + Setting.redemption_grace_period.days
|
@domain.delete_at.should be_within(5).of(valid_to + Setting.expire_warning_period.days + Setting.redemption_grace_period.days)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should validate uniqueness of tech contacts' do
|
it 'should validate uniqueness of tech contacts' do
|
||||||
|
@ -93,13 +93,16 @@ describe Domain do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should expire domains' do
|
it 'should expire domains' do
|
||||||
Domain.expire_domains
|
Domain.start_expire_period
|
||||||
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0
|
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0
|
||||||
|
|
||||||
@domain.valid_to = Time.zone.now - 10.days
|
@domain.valid_to = Time.zone.now - 10.days
|
||||||
@domain.save
|
@domain.save
|
||||||
|
|
||||||
Domain.expire_domains
|
Domain.start_expire_period
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
||||||
|
|
||||||
|
Domain.start_expire_period
|
||||||
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -108,12 +111,35 @@ describe Domain do
|
||||||
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
||||||
|
|
||||||
@domain.outzone_at = Time.zone.now
|
@domain.outzone_at = Time.zone.now
|
||||||
|
@domain.domain_statuses.create(value: DomainStatus::SERVER_MANUAL_INZONE) # this prohibits server_hold
|
||||||
@domain.save
|
@domain.save
|
||||||
|
|
||||||
|
Domain.start_redemption_grace_period
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
||||||
|
|
||||||
|
@domain.domain_statuses.destroy_all
|
||||||
|
|
||||||
Domain.start_redemption_grace_period
|
Domain.start_redemption_grace_period
|
||||||
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1
|
@domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should start delete period' do
|
||||||
|
Domain.start_delete_period
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 0
|
||||||
|
|
||||||
|
@domain.delete_at = Time.zone.now
|
||||||
|
@domain.domain_statuses.create(value: DomainStatus::SERVER_DELETE_PROHIBITED) # this prohibits delete_candidate
|
||||||
|
@domain.save
|
||||||
|
|
||||||
|
Domain.start_delete_period
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 0
|
||||||
|
|
||||||
|
@domain.domain_statuses.destroy_all
|
||||||
|
Domain.start_delete_period
|
||||||
|
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).count.should == 1
|
||||||
|
end
|
||||||
|
|
||||||
context 'about registrant update confirm' do
|
context 'about registrant update confirm' do
|
||||||
before :all do
|
before :all do
|
||||||
@domain.registrant_verification_token = 123
|
@domain.registrant_verification_token = 123
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue