mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Add test #2622
This commit is contained in:
parent
d9aaab1e92
commit
cd1f04f155
3 changed files with 34 additions and 7 deletions
|
@ -221,6 +221,18 @@ class Domain < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
def renewable?
|
||||
if Setting.days_to_renew_domain_before_expire != 0
|
||||
if (valid_to - Time.zone.now).to_i / 1.day >= Setting.days_to_renew_domain_before_expire
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return false if domain_statuses.where(value: DomainStatus::DELETE_CANDIDATE).any?
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def pending_update?
|
||||
(domain_statuses.pluck(:value) & %W(
|
||||
#{DomainStatus::PENDING_UPDATE}
|
||||
|
|
|
@ -427,21 +427,16 @@ class Epp::Domain < Domain
|
|||
### RENEW ###
|
||||
|
||||
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 Setting.days_to_renew_domain_before_expire != 0
|
||||
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
|
||||
end
|
||||
|
||||
add_epp_error('2105', nil, nil, I18n.t('object_is_not_eligible_for_renewal')) unless renewable?
|
||||
return false if errors.any?
|
||||
|
||||
p = self.class.convert_period_to_time(period, unit)
|
||||
self.valid_to = valid_to + p
|
||||
self.period = period
|
||||
self.period_unit = unit
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
|
|
|
@ -2047,6 +2047,26 @@ describe 'EPP Domain', epp: true do
|
|||
Setting.days_to_renew_domain_before_expire = 90
|
||||
end
|
||||
|
||||
it 'does not renew a domain if it is a delete candidate' do
|
||||
domain.valid_to = Time.zone.now + 10.days
|
||||
domain.delete_at = Time.zone.now
|
||||
domain.save
|
||||
|
||||
Domain.start_delete_period
|
||||
|
||||
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'
|
||||
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