mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 08:43:37 +02:00
Add feature to specify days to allow renew before expiration #2610
This commit is contained in:
parent
315a5a4aae
commit
7afca86c0e
5 changed files with 53 additions and 2 deletions
|
@ -429,6 +429,11 @@ class Epp::Domain < Domain
|
|||
def renew(cur_exp_date, period, unit = 'y')
|
||||
# TODO: Check how much time before domain exp date can it be renewed
|
||||
validate_exp_dates(cur_exp_date)
|
||||
|
||||
if (valid_to - Time.zone.now).to_i / 1.day >= Setting.days_to_renew_domain_before_expire
|
||||
add_epp_error('2105', nil, nil, I18n.t('object_is_not_eligible_for_renewal'))
|
||||
end
|
||||
|
||||
return false if errors.any?
|
||||
|
||||
p = self.class.convert_period_to_time(period, unit)
|
||||
|
|
|
@ -31,6 +31,7 @@ if con.present? && con.table_exists?('settings')
|
|||
Setting.save_default(:invoice_number_min, '131050')
|
||||
Setting.save_default(:invoice_number_max, '149999')
|
||||
Setting.save_default(:days_to_keep_overdue_invoices_active, 30)
|
||||
Setting.save_default(:days_to_renew_domain_before_expire, 90)
|
||||
end
|
||||
|
||||
# dev only setting
|
||||
|
|
|
@ -816,3 +816,4 @@ en:
|
|||
new_pricelist: New Pricelist
|
||||
valid: Valid
|
||||
category: Zone
|
||||
object_is_not_eligible_for_renewal: 'Object is not eligible for renewal'
|
||||
|
|
9
db/data/20150609093515_add_renew_setting.rb
Normal file
9
db/data/20150609093515_add_renew_setting.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AddRenewSetting < ActiveRecord::Migration
|
||||
def self.up
|
||||
Setting.days_to_renew_domain_before_expire = 90
|
||||
end
|
||||
|
||||
def self.down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
|
@ -1949,7 +1949,10 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
### RENEW ###
|
||||
it 'renews a domain' do
|
||||
exp_date = 1.year.since.to_date
|
||||
domain.valid_to = Time.zone.now.to_date + 10.days
|
||||
domain.save
|
||||
|
||||
exp_date = domain.valid_to.to_date
|
||||
xml = @epp_xml.domain.renew(
|
||||
name: { value: domain.name },
|
||||
curExpDate: { value: exp_date.to_s },
|
||||
|
@ -1979,7 +1982,9 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'returns an error when period is invalid' do
|
||||
exp_date = (1.year.since.to_date)
|
||||
domain.valid_to = Time.zone.now.to_date + 10.days
|
||||
domain.save
|
||||
exp_date = domain.valid_to.to_date
|
||||
|
||||
xml = @epp_xml.domain.renew(
|
||||
name: { value: domain.name },
|
||||
|
@ -1993,6 +1998,36 @@ describe 'EPP Domain', epp: true do
|
|||
response[:results][0][:value].should == '4'
|
||||
end
|
||||
|
||||
it 'does not renew a domain unless less than 90 days till expiration' do
|
||||
domain.valid_to = Time.zone.now.to_date + 91.days
|
||||
domain.save
|
||||
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 == 'Object is not eligible for renewal'
|
||||
response[:results][0][:result_code].should == '2105'
|
||||
|
||||
domain.valid_to = Time.zone.now.to_date + 90.days
|
||||
domain.save
|
||||
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'
|
||||
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