mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Add domain expiration procedure #2622
This commit is contained in:
parent
e2df9b7e19
commit
432e8a95ec
3 changed files with 26 additions and 0 deletions
|
@ -146,6 +146,12 @@ class Domain < ActiveRecord::Base
|
||||||
{ admin_contacts: :registrar }
|
{ admin_contacts: :registrar }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expire_domains
|
||||||
|
Domain.where('valid_to <= ?', Time.zone.now).each do |x|
|
||||||
|
x.domain_statuses.create(value: DomainStatus::EXPIRED) if x.expirable?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
|
@ -174,6 +180,11 @@ class Domain < ActiveRecord::Base
|
||||||
)).empty?
|
)).empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expirable?
|
||||||
|
return false if valid_to > Time.zone.now
|
||||||
|
domain_statuses.where(value: DomainStatus::EXPIRED).empty?
|
||||||
|
end
|
||||||
|
|
||||||
def pending_update?
|
def pending_update?
|
||||||
(domain_statuses.pluck(:value) & %W(
|
(domain_statuses.pluck(:value) & %W(
|
||||||
#{DomainStatus::PENDING_UPDATE}
|
#{DomainStatus::PENDING_UPDATE}
|
||||||
|
|
|
@ -24,6 +24,10 @@ every :day, at: '12:10pm' do
|
||||||
runner 'Invoice.cancel_overdue_invoices'
|
runner 'Invoice.cancel_overdue_invoices'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
every :day, at: '12:15pm' do
|
||||||
|
runner 'Domain.expire_domains'
|
||||||
|
end
|
||||||
|
|
||||||
every 3.hours do
|
every 3.hours do
|
||||||
runner 'Certificate.update_crl'
|
runner 'Certificate.update_crl'
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,6 +85,17 @@ describe Domain do
|
||||||
@domain.registrant_update_confirmable?('123').should == false
|
@domain.registrant_update_confirmable?('123').should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should expire domains' do
|
||||||
|
Domain.expire_domains
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0
|
||||||
|
|
||||||
|
@domain.valid_to = Time.zone.now - 10.days
|
||||||
|
@domain.save
|
||||||
|
|
||||||
|
Domain.expire_domains
|
||||||
|
@domain.domain_statuses.where(value: DomainStatus::EXPIRED).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