diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 72fd602b6..7c837d8fd 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -399,7 +399,7 @@ class Epp::Domain < Domain statuses.delete(DomainStatus::PENDING_UPDATE) return unless update(frame, user, false) - clean_pendings! + clean_pendings! self.deliver_emails = true # turn on email delivery for epp DomainMailer.registrant_updated(self).deliver_now end @@ -446,8 +446,8 @@ class Epp::Domain < Domain p = self.class.convert_period_to_time(period, unit) self.valid_to = valid_to + p - self.outzone_at = outzone_at + p - self.delete_at = delete_at + p + self.outzone_at = valid_to + Setting.expire_warning_period.days + self.delete_at = outzone_at + Setting.redemption_grace_period.days self.period = period self.period_unit = unit diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 7aece6e9d..33d4819d0 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -2185,16 +2185,14 @@ describe 'EPP Domain', epp: true do ### RENEW ### it 'renews a domain' do + Setting.days_to_renew_domain_before_expire = 0 old_balance = @registrar1.balance old_activities = @registrar1.cash_account.account_activities.count - domain.valid_to = Time.zone.now.to_date + 10.days - domain.save - - exp_date = domain.valid_to.to_date + exp_date = domain.valid_to xml = @epp_xml.domain.renew( name: { value: domain.name }, - curExpDate: { value: exp_date.to_s }, + curExpDate: { value: exp_date.to_date.to_s }, period: { value: '1', attrs: { unit: 'y' } } ) @@ -2204,9 +2202,16 @@ describe 'EPP Domain', epp: true do ex_date = response[:parsed].css('renData exDate').text name = response[:parsed].css('renData name').text - ex_date.should == "#{(exp_date + 1.year)}T00:00:00Z" + ex_date.should == "#{(exp_date + 1.year).to_s(:iso8601)}" name.should == domain.name + domain.reload + domain.valid_to.should be_within(1).of(exp_date + 1.year) + domain.outzone_at.should be_within(1).of(exp_date + 1.year + Setting.expire_warning_period.days) + domain.delete_at.should be_within(1).of( + exp_date + 1.year + Setting.expire_warning_period.days + Setting.redemption_grace_period.days + ) + @registrar1.balance.should == old_balance - 15.0 @registrar1.cash_account.account_activities.count.should == old_activities + 1 a = @registrar1.cash_account.account_activities.last @@ -2214,6 +2219,28 @@ describe 'EPP Domain', epp: true do a.sum.should == -BigDecimal.new('15.0') a.activity_type = AccountActivity::RENEW a.log_pricelist_id.should == @pricelist_renew_1_year.id + Setting.days_to_renew_domain_before_expire = 90 + end + + it 'renews a domain when outzone_at or delete_at is nil for some reason' do + Setting.days_to_renew_domain_before_expire = 0 + + domain.outzone_at = nil + domain.delete_at = nil + domain.save + + exp_date = domain.valid_to + xml = @epp_xml.domain.renew( + name: { value: domain.name }, + curExpDate: { value: exp_date.to_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 'renews a domain with 2 year period' do