diff --git a/app/models/domain.rb b/app/models/domain.rb index 16d96bb09..4490c1ad4 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -245,7 +245,7 @@ class Domain < ActiveRecord::Base def renewable? if Setting.days_to_renew_domain_before_expire != 0 - if ((valid_to - Time.zone.now).to_i / 1.day) + 1 >= Setting.days_to_renew_domain_before_expire + if ((valid_to - Time.zone.now.beginning_of_day).to_i / 1.day) + 1 >= Setting.days_to_renew_domain_before_expire return false end end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 2b4de33d5..885d4324d 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1999,7 +1999,8 @@ describe 'EPP Domain', epp: true do end it 'does not renew a domain unless less than 90 days till expiration' do - domain.valid_to = Time.zone.now.to_date + 90.days + # both days are inclusive + domain.valid_to = Time.zone.now.to_date + 89.days domain.save exp_date = domain.valid_to.to_date @@ -2013,7 +2014,7 @@ describe 'EPP Domain', epp: true do 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 + 89.days + domain.valid_to = Time.zone.now.to_date + 88.days domain.save exp_date = domain.valid_to.to_date