Add a test to domain renew

This commit is contained in:
Martin Lensment 2014-08-11 11:48:03 +03:00
parent 8baa2e12c9
commit a3abfa73e5
5 changed files with 29 additions and 6 deletions

View file

@ -32,6 +32,7 @@ module Epp::DomainsHelper
end
def renew_domain
# TODO support period unit
@domain = find_domain
handle_errors(@domain) and return unless @domain
@ -49,11 +50,11 @@ module Epp::DomainsHelper
end
def find_domain
@domain = Domain.find_by(name: @ph[:name])
unless @domain
domain = Domain.find_by(name: @ph[:name])
unless domain
epp_errors << {code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: {obj: 'name', val: @ph[:name]}}
end
@domain
domain
end
def domain_create_params(ph)

View file

@ -7,7 +7,7 @@ class Domain < ActiveRecord::Base
EPP_CODE_MAP = {
'2302' => ['Domain name already exists', 'Domain name is reserved or restricted'], # Object exists
'2306' => ['Registrant is missing', 'Admin contact is missing', 'Given and current expire dates do not match'], # Parameter policy error
'2004' => ['Nameservers count must be between 1-13'], # Parameter value range error
'2004' => ['Nameservers count must be between 1-13', 'Period must add up to 1, 2 or 3 years'], # Parameter value range error
'2303' => ['Contact was not found'] # Object does not exist
}
@ -136,7 +136,6 @@ class Domain < ActiveRecord::Base
def validate_period
return unless period.present?
if period_unit == 'd'
valid_values = ['365', '366', '710', '712', '1065', '1068']
elsif period_unit == 'm'
@ -145,7 +144,7 @@ class Domain < ActiveRecord::Base
valid_values = ['1', '2', '3']
end
errors.add(:period, :step_error) unless valid_values.include?(period.to_s)
errors.add(:period, :out_of_range) unless valid_values.include?(period.to_s)
end
def validate_exp_dates(cur_exp_date)