mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Full period unit support
This commit is contained in:
parent
9371b2ad67
commit
73cb8c604d
3 changed files with 14 additions and 5 deletions
|
@ -36,6 +36,10 @@ module Epp::DomainsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_create_params
|
def domain_create_params
|
||||||
|
period = (@ph[:period].to_i == 0) ? 1 : @ph[:period].to_i
|
||||||
|
period_unit = Domain.parse_period_unit_from_frame(parsed_frame) || 'y'
|
||||||
|
valid_to = Date.today + Domain.convert_period_to_time(period, period_unit)
|
||||||
|
|
||||||
{
|
{
|
||||||
name: @ph[:name],
|
name: @ph[:name],
|
||||||
registrar_id: current_epp_user.registrar.try(:id),
|
registrar_id: current_epp_user.registrar.try(:id),
|
||||||
|
@ -43,7 +47,7 @@ module Epp::DomainsHelper
|
||||||
period: (@ph[:period].to_i == 0) ? 1 : @ph[:period].to_i,
|
period: (@ph[:period].to_i == 0) ? 1 : @ph[:period].to_i,
|
||||||
period_unit: Domain.parse_period_unit_from_frame(parsed_frame) || 'y',
|
period_unit: Domain.parse_period_unit_from_frame(parsed_frame) || 'y',
|
||||||
valid_from: Date.today,
|
valid_from: Date.today,
|
||||||
valid_to: Date.today + @ph[:period].to_i.years,
|
valid_to: valid_to,
|
||||||
auth_info: @ph[:authInfo][:pw]
|
auth_info: @ph[:authInfo][:pw]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -130,9 +130,7 @@ class Domain < ActiveRecord::Base
|
||||||
validate_exp_dates(cur_exp_date)
|
validate_exp_dates(cur_exp_date)
|
||||||
return false if errors.any?
|
return false if errors.any?
|
||||||
|
|
||||||
p = period.to_i.days if unit == 'd'
|
p = self.class.convert_period_to_time(period, unit)
|
||||||
p = period.to_i.months if unit == 'm'
|
|
||||||
p = period.to_i.years if unit == 'y'
|
|
||||||
|
|
||||||
self.valid_to = self.valid_to + p
|
self.valid_to = self.valid_to + p
|
||||||
self.period = period
|
self.period = period
|
||||||
|
@ -174,6 +172,13 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
def convert_period_to_time(period, unit)
|
||||||
|
p = period.to_i.days if unit == 'd'
|
||||||
|
p = period.to_i.months if unit == 'm'
|
||||||
|
p = period.to_i.years if unit == 'y'
|
||||||
|
p
|
||||||
|
end
|
||||||
|
|
||||||
def parse_contacts_from_frame(parsed_frame)
|
def parse_contacts_from_frame(parsed_frame)
|
||||||
res = {}
|
res = {}
|
||||||
Contact::CONTACT_TYPES.each do |ct|
|
Contact::CONTACT_TYPES.each do |ct|
|
||||||
|
|
|
@ -102,7 +102,7 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:results][0][:msg]).to eq 'IP is invalid'
|
expect(response[:results][0][:msg]).to eq 'IP is invalid'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a domain with period in days', pending: true do
|
it 'creates a domain with period in days' do
|
||||||
response = epp_request('domains/create_w_period_in_days.xml')
|
response = epp_request('domains/create_w_period_in_days.xml')
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue