mirror of
https://github.com/internetee/registry.git
synced 2025-05-31 01:43:56 +02:00
Add period unit support to domain price method #2741
This commit is contained in:
parent
98439b896c
commit
61dfe6e1f3
2 changed files with 26 additions and 1 deletions
|
@ -374,7 +374,12 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def price(operation)
|
def price(operation)
|
||||||
zone = name.split('.').drop(1).join('.')
|
zone = name.split('.').drop(1).join('.')
|
||||||
p = "#{self.period}year"
|
|
||||||
|
p = period / 365 if period_unit == 'd'
|
||||||
|
p = period / 12 if period_unit == 'm'
|
||||||
|
p = period if period_unit == 'y'
|
||||||
|
|
||||||
|
p = "#{p}year"
|
||||||
Pricelist.price_for(zone, operation, p)
|
Pricelist.price_for(zone, operation, p)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,26 @@ describe Domain do
|
||||||
@domain.force_delete_at.should be_nil
|
@domain.force_delete_at.should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should know its price' do
|
||||||
|
Fabricate(:pricelist, {
|
||||||
|
category: 'ee',
|
||||||
|
operation_category: 'create',
|
||||||
|
duration: '1year',
|
||||||
|
price: 1.50,
|
||||||
|
valid_from: Time.zone.parse('2015-01-01'),
|
||||||
|
valid_to: nil
|
||||||
|
})
|
||||||
|
|
||||||
|
domain = Fabricate(:domain)
|
||||||
|
domain.price('create').should == 1.50
|
||||||
|
|
||||||
|
domain = Fabricate(:domain, period: 12, period_unit: 'm')
|
||||||
|
domain.price('create').should == 1.50
|
||||||
|
|
||||||
|
domain = Fabricate(:domain, period: 365, period_unit: 'd')
|
||||||
|
domain.price('create').should == 1.50
|
||||||
|
end
|
||||||
|
|
||||||
context 'about registrant update confirm' do
|
context 'about registrant update confirm' do
|
||||||
before :all do
|
before :all do
|
||||||
@domain.registrant_verification_token = 123
|
@domain.registrant_verification_token = 123
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue