Allow renew when some fields are nil #2777

This commit is contained in:
Martin Lensment 2015-07-16 14:07:18 +03:00
parent 968f5d180d
commit 9bc4e4a697
2 changed files with 36 additions and 9 deletions

View file

@ -446,8 +446,8 @@ class Epp::Domain < Domain
p = self.class.convert_period_to_time(period, unit) p = self.class.convert_period_to_time(period, unit)
self.valid_to = valid_to + p self.valid_to = valid_to + p
self.outzone_at = outzone_at + p self.outzone_at = valid_to + Setting.expire_warning_period.days
self.delete_at = delete_at + p self.delete_at = outzone_at + Setting.redemption_grace_period.days
self.period = period self.period = period
self.period_unit = unit self.period_unit = unit

View file

@ -2185,16 +2185,14 @@ describe 'EPP Domain', epp: true do
### RENEW ### ### RENEW ###
it 'renews a domain' do it 'renews a domain' do
Setting.days_to_renew_domain_before_expire = 0
old_balance = @registrar1.balance old_balance = @registrar1.balance
old_activities = @registrar1.cash_account.account_activities.count old_activities = @registrar1.cash_account.account_activities.count
domain.valid_to = Time.zone.now.to_date + 10.days exp_date = domain.valid_to
domain.save
exp_date = domain.valid_to.to_date
xml = @epp_xml.domain.renew( xml = @epp_xml.domain.renew(
name: { value: domain.name }, name: { value: domain.name },
curExpDate: { value: exp_date.to_s }, curExpDate: { value: exp_date.to_date.to_s },
period: { value: '1', attrs: { unit: 'y' } } period: { value: '1', attrs: { unit: 'y' } }
) )
@ -2204,9 +2202,16 @@ describe 'EPP Domain', epp: true do
ex_date = response[:parsed].css('renData exDate').text ex_date = response[:parsed].css('renData exDate').text
name = response[:parsed].css('renData name').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 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.balance.should == old_balance - 15.0
@registrar1.cash_account.account_activities.count.should == old_activities + 1 @registrar1.cash_account.account_activities.count.should == old_activities + 1
a = @registrar1.cash_account.account_activities.last 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.sum.should == -BigDecimal.new('15.0')
a.activity_type = AccountActivity::RENEW a.activity_type = AccountActivity::RENEW
a.log_pricelist_id.should == @pricelist_renew_1_year.id 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 end
it 'renews a domain with 2 year period' do it 'renews a domain with 2 year period' do