mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Add tests #2741
This commit is contained in:
parent
2f0666dec3
commit
9e1aabe6d3
2 changed files with 38 additions and 4 deletions
|
@ -146,9 +146,9 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def convert_period_to_time(period, unit)
|
def convert_period_to_time(period, unit)
|
||||||
return period.to_i.days if unit == 'd'
|
return (period.to_i / 365).years if unit == 'd'
|
||||||
return period.to_i.months if unit == 'm'
|
return (period.to_i / 12).years if unit == 'm'
|
||||||
return period.to_i.years if unit == 'y'
|
return period.to_i.years if unit == 'y'
|
||||||
end
|
end
|
||||||
|
|
||||||
def included
|
def included
|
||||||
|
|
|
@ -20,6 +20,8 @@ describe 'EPP Domain', epp: true do
|
||||||
Fabricate(:reserved_domain)
|
Fabricate(:reserved_domain)
|
||||||
Fabricate(:blocked_domain)
|
Fabricate(:blocked_domain)
|
||||||
Fabricate(:pricelist, valid_to: nil)
|
Fabricate(:pricelist, valid_to: nil)
|
||||||
|
Fabricate(:pricelist, duration: '2years', price: 20, valid_to: nil)
|
||||||
|
Fabricate(:pricelist, duration: '3years', price: 30, valid_to: nil)
|
||||||
Fabricate(:pricelist, operation_category: 'renew', price: 15, valid_to: nil)
|
Fabricate(:pricelist, operation_category: 'renew', price: 15, valid_to: nil)
|
||||||
|
|
||||||
@uniq_no = proc { @i ||= 0; @i += 1 }
|
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||||
|
@ -341,7 +343,7 @@ describe 'EPP Domain', epp: true do
|
||||||
it 'creates a domain with period in days' do
|
it 'creates a domain with period in days' do
|
||||||
old_balance = @registrar1.balance
|
old_balance = @registrar1.balance
|
||||||
old_activities = @registrar1.cash_account.account_activities.count
|
old_activities = @registrar1.cash_account.account_activities.count
|
||||||
xml = domain_create_xml(period_value: 365, period_unit: 'd')
|
xml = domain_create_xml(period: { value: '365', attrs: { unit: 'd' }})
|
||||||
|
|
||||||
response = epp_plain_request(xml)
|
response = epp_plain_request(xml)
|
||||||
response[:msg].should == 'Command completed successfully'
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
@ -354,6 +356,38 @@ describe 'EPP Domain', epp: true do
|
||||||
a.sum.should == -BigDecimal.new('10.0')
|
a.sum.should == -BigDecimal.new('10.0')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates a domain with longer periods' do
|
||||||
|
old_balance = @registrar1.balance
|
||||||
|
old_activities = @registrar1.cash_account.account_activities.count
|
||||||
|
xml = domain_create_xml(period: { value: '2', attrs: { unit: 'y' }})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
Domain.last.valid_to.should be_within(60).of(2.years.since)
|
||||||
|
@registrar1.balance.should be < old_balance
|
||||||
|
@registrar1.cash_account.account_activities.count.should == old_activities + 1
|
||||||
|
a = @registrar1.cash_account.account_activities.last
|
||||||
|
a.description.should == "Create #{Domain.last.name}"
|
||||||
|
a.sum.should == -BigDecimal.new('20.0')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates a domain with longer periods' do
|
||||||
|
old_balance = @registrar1.balance
|
||||||
|
old_activities = @registrar1.cash_account.account_activities.count
|
||||||
|
xml = domain_create_xml(period: { value: '36', attrs: { unit: 'm' }})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
Domain.last.valid_to.should be_within(60).of(3.years.since)
|
||||||
|
@registrar1.balance.should be < old_balance
|
||||||
|
@registrar1.cash_account.account_activities.count.should == old_activities + 1
|
||||||
|
a = @registrar1.cash_account.account_activities.last
|
||||||
|
a.description.should == "Create #{Domain.last.name}"
|
||||||
|
a.sum.should == -BigDecimal.new('30.0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not create a domain with invalid period' do
|
it 'does not create a domain with invalid period' do
|
||||||
old_balance = @registrar1.balance
|
old_balance = @registrar1.balance
|
||||||
old_activities = @registrar1.cash_account.account_activities.count
|
old_activities = @registrar1.cash_account.account_activities.count
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue