mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
b1fb8b07c9
4 changed files with 64 additions and 3 deletions
|
@ -148,27 +148,48 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def start_expire_period
|
||||
Domain.where('valid_to <= ?', Time.zone.now).each do |x|
|
||||
logger.info "#{Time.zone.now.utc} - Expiring domains\n"
|
||||
|
||||
d = Domain.where('valid_to <= ?', Time.zone.now)
|
||||
d.each do |x|
|
||||
x.domain_statuses.create(value: DomainStatus::EXPIRED) if x.expirable?
|
||||
end
|
||||
|
||||
logger.info "#{Time.zone.now.utc} - Successfully expired #{d.count} domains\n"
|
||||
end
|
||||
|
||||
def start_redemption_grace_period
|
||||
Domain.where('outzone_at <= ?', Time.zone.now).each do |x|
|
||||
logger.info "#{Time.zone.now.utc} - Setting server_hold to domains\n"
|
||||
|
||||
d = Domain.where('outzone_at <= ?', Time.zone.now)
|
||||
d.each do |x|
|
||||
x.domain_statuses.create(value: DomainStatus::SERVER_HOLD) if x.server_holdable?
|
||||
end
|
||||
|
||||
logger.info "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n"
|
||||
end
|
||||
|
||||
def start_delete_period
|
||||
Domain.where('delete_at <= ?', Time.zone.now).each do |x|
|
||||
logger.info "#{Time.zone.now.utc} - Setting delete_candidate to domains\n"
|
||||
|
||||
d = Domain.where('delete_at <= ?', Time.zone.now)
|
||||
d.each do |x|
|
||||
x.domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if x.delete_candidateable?
|
||||
end
|
||||
|
||||
logger.info "#{Time.zone.now.utc} - Successfully set delete_candidate to #{d.count} domains\n"
|
||||
end
|
||||
|
||||
def destroy_delete_candidates
|
||||
logger.info "#{Time.zone.now.utc} - Destroying domains\n"
|
||||
|
||||
c = 0
|
||||
DomainStatus.where(value: DomainStatus::DELETE_CANDIDATE).each do |x|
|
||||
x.domain.destroy
|
||||
c += 1
|
||||
end
|
||||
|
||||
logger.info "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -437,6 +437,9 @@ class Epp::Domain < Domain
|
|||
self.period = period
|
||||
self.period_unit = unit
|
||||
|
||||
domain_statuses.where(value: DomainStatus::SERVER_HOLD).destroy_all
|
||||
domain_statuses.where(value: DomainStatus::EXPIRED).destroy_all
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
|
|
10
db/data/20150610111019_add_expire_settings.rb
Normal file
10
db/data/20150610111019_add_expire_settings.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class AddExpireSettings < ActiveRecord::Migration
|
||||
def self.up
|
||||
Setting.expire_warning_period = 15
|
||||
Setting.redemption_grace_period = 30
|
||||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
|
@ -2067,6 +2067,33 @@ describe 'EPP Domain', epp: true do
|
|||
response[:results][0][:result_code].should == '2105'
|
||||
end
|
||||
|
||||
it 'should renew a expired domain' do
|
||||
domain.valid_to = Time.zone.now - 50.days
|
||||
domain.outzone_at = Time.zone.now - 50.days
|
||||
domain.save
|
||||
|
||||
Domain.start_expire_period
|
||||
Domain.start_redemption_grace_period
|
||||
|
||||
domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 1
|
||||
domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 1
|
||||
|
||||
exp_date = domain.valid_to.to_date
|
||||
|
||||
xml = @epp_xml.domain.renew(
|
||||
name: { value: domain.name },
|
||||
curExpDate: { value: exp_date.to_s },
|
||||
period: { value: '1', attrs: { unit: 'y' } }
|
||||
)
|
||||
|
||||
response = epp_plain_request(xml)
|
||||
response[:results][0][:msg].should == 'Command completed successfully'
|
||||
response[:results][0][:result_code].should == '1000'
|
||||
|
||||
domain.domain_statuses.where(value: DomainStatus::EXPIRED).count.should == 0
|
||||
domain.domain_statuses.where(value: DomainStatus::SERVER_HOLD).count.should == 0
|
||||
end
|
||||
|
||||
it 'does not renew foreign domain' do
|
||||
login_as :registrar2 do
|
||||
exp_date = 1.year.since.to_date
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue