Improve EPP domain:renew specs

#430
This commit is contained in:
Artur Beljajev 2017-04-16 17:16:40 +03:00
parent 6c3a96b2ec
commit 87f48d6788
3 changed files with 91 additions and 2 deletions

View file

@ -0,0 +1,89 @@
require 'rails_helper'
RSpec.describe 'EPP domain:renew' do
let(:request) { post '/epp/command/renew', frame: request_xml }
let!(:user) { create(:api_user_epp, registrar: registrar) }
let!(:pricelist) { create(:pricelist,
category: 'com',
duration: '1year',
price: Money.from_amount(1),
operation_category: 'renew',
valid_from: Time.zone.parse('05.07.2010'),
valid_to: Time.zone.parse('05.07.2010'))
}
before :example do
travel_to Time.zone.parse('05.07.2010')
sign_in_to_epp_area(user: user)
end
context 'when account balance is sufficient' do
let!(:registrar) { create(:registrar_with_unlimited_balance) }
let!(:domain) { create(:domain,
registrar: registrar,
name: 'test.com',
expire_time: Time.zone.parse('05.07.2010'))
}
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>test.com</domain:name>
<domain:curExpDate>2010-07-05</domain:curExpDate>
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
}
it 'renews domain' do
request
domain.reload
expect(domain.expire_time).to eq(Time.zone.parse('05.07.2011'))
end
specify do
request
expect(response).to have_code_of(1000)
end
end
context 'when account balance is not sufficient' do
let!(:registrar) { create(:registrar_with_zero_balance) }
let!(:domain) { create(:domain,
registrar: registrar,
name: 'test.com',
expire_time: Time.zone.parse('05.07.2010'))
}
let(:request_xml) { <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>test.com</domain:name>
<domain:curExpDate>2010-07-04</domain:curExpDate>
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
}
it 'does not renew domain' do
request
domain.reload
expect(domain.expire_time).to eq(Time.zone.parse('05.07.2010'))
end
specify do
request
expect(response).to have_code_of(2104)
end
end
end

View file

@ -18,7 +18,7 @@ RSpec.describe 'EPP domain:renew' do
sign_in_to_epp_area(user: user) sign_in_to_epp_area(user: user)
end end
context 'when given expire time is the same as current' do context 'when given expire time and current match' do
let!(:domain) { create(:domain, let!(:domain) { create(:domain,
registrar: registrar, registrar: registrar,
name: 'test.com', name: 'test.com',
@ -52,7 +52,7 @@ RSpec.describe 'EPP domain:renew' do
end end
end end
context 'when given expire time is not the same as current' do context 'when given expire time and current do not match' do
let!(:domain) { create(:domain, let!(:domain) { create(:domain,
registrar: registrar, registrar: registrar,
name: 'test.com', name: 'test.com',