From 81169e9fbcd4b3c0b0d1fbe42e6234fe192eb3c7 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 9 Jun 2015 16:03:09 +0300 Subject: [PATCH] Allow domain renew indefinitely #2610 --- app/models/epp/domain.rb | 6 ++++-- spec/epp/domain_spec.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index ecd13ad55..4ecb83c69 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -430,8 +430,10 @@ class Epp::Domain < Domain # 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')) + 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 return false if errors.any? diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index b3321641b..2575aca3c 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -2028,6 +2028,25 @@ describe 'EPP Domain', epp: true do response[:results][0][:result_code].should == '1000' end + it 'does not renew a domain unless less than 90 days till expiration' do + Setting.days_to_renew_domain_before_expire = 0 + + domain.valid_to = Time.zone.now.to_date + 5.years + 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' + Setting.days_to_renew_domain_before_expire = 90 + end + it 'does not renew foreign domain' do login_as :registrar2 do exp_date = 1.year.since.to_date