mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Working domain renewal
This commit is contained in:
parent
218ecb3317
commit
684a4ab4f1
4 changed files with 14 additions and 6 deletions
|
@ -125,13 +125,14 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def renew(cur_exp_date, period, unit='y')
|
def renew(cur_exp_date, period, unit='y')
|
||||||
if cur_exp_date == valid_to
|
if cur_exp_date.to_date == valid_to
|
||||||
valid_to = period.to_i.years
|
self.valid_to = self.valid_to + period.to_i.years
|
||||||
|
self.period = period
|
||||||
|
save
|
||||||
else
|
else
|
||||||
errors[:base] << {msg: I18n.t('errors.messages.epp_exp_dates_do_not_match'), obj: 'domain', val: cur_exp_date}
|
errors[:base] << {msg: I18n.t('errors.messages.epp_exp_dates_do_not_match'), obj: 'domain', val: cur_exp_date}
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
|
@ -134,7 +134,13 @@ describe 'EPP Domain', epp: true do
|
||||||
context 'with valid domain' do
|
context 'with valid domain' do
|
||||||
before(:each) { Fabricate(:domain, name: 'example.ee') }
|
before(:each) { Fabricate(:domain, name: 'example.ee') }
|
||||||
|
|
||||||
|
it 'renews a domain' do
|
||||||
|
response = epp_request('domains/renew.xml')
|
||||||
|
exDate = response[:parsed].css('renData exDate').text
|
||||||
|
name = response[:parsed].css('renData name').text
|
||||||
|
expect(exDate).to eq ('2015-08-07 00:00:00 UTC')
|
||||||
|
expect(name).to eq ('example.ee')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks a domain' do
|
it 'checks a domain' do
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<domain:renew
|
<domain:renew
|
||||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
<domain:name>example.ee</domain:name>
|
<domain:name>example.ee</domain:name>
|
||||||
<domain:curExpDate>2000-04-03</domain:curExpDate>
|
<domain:curExpDate>2014-08-07</domain:curExpDate>
|
||||||
<domain:period unit="y">1</domain:period>
|
<domain:period unit="y">1</domain:period>
|
||||||
</domain:renew>
|
</domain:renew>
|
||||||
</renew>
|
</renew>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Fabricator(:domain) do
|
Fabricator(:domain) do
|
||||||
name { "#{Faker::Internet.domain_word}.ee" }
|
name { "#{Faker::Internet.domain_word}.ee" }
|
||||||
|
valid_to Date.new(2014, 8, 7)
|
||||||
period 1
|
period 1
|
||||||
owner_contact(fabricator: :contact)
|
owner_contact(fabricator: :contact)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue