Merge branch 'master' into registry-791

This commit is contained in:
Artur Beljajev 2018-04-20 17:37:43 +03:00
commit 696a3871b7
114 changed files with 905 additions and 440 deletions

View file

@ -3,6 +3,7 @@ FactoryBot.define do
sequence(:name) { |n| "test#{n}.com" }
period 1
period_unit 'y' # Year
valid_to Time.zone.parse('2010-07-05')
registrar
registrant
@ -10,9 +11,5 @@ FactoryBot.define do
domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact)
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
end
factory :domain_discarded do
statuses [DomainStatus::DELETE_CANDIDATE]
end
end
end

View file

@ -3,12 +3,11 @@ FactoryBot.define do
buyer_name 'Registrar 1'
currency { 'EUR' }
due_date { Time.zone.now.to_date + 1.day }
invoice_type 'DEB'
seller_iban { '123' }
seller_name { 'EIS' }
seller_city { 'Tallinn' }
seller_street { 'Paldiski mnt. 123' }
vat_prc 0.2
vat_rate 0.2
buyer { FactoryBot.create(:registrar) }
after :build do |invoice|

View file

@ -1,19 +0,0 @@
require 'rails_helper'
RSpec.describe Domain, db: false do
it { is_expected.to alias_attribute(:delete_time, :delete_at) }
describe '#discarded?' do
context 'when :deleteCandidate status is present' do
let(:domain) { described_class.new(statuses: [DomainStatus::DELETE_CANDIDATE]) }
specify { expect(domain).to be_discarded }
end
context 'when :deleteCandidate status is absent' do
let(:domain) { described_class.new(statuses: []) }
specify { expect(domain).to_not be_discarded }
end
end
end

View file

@ -21,11 +21,7 @@ RSpec.describe Epp::Domain, db: false do
expect(domain.registered_at).to eq(Time.zone.parse('05.07.2010'))
end
it 'has :valid_from set to now' do
expect(domain.valid_from).to eq(Time.zone.parse('05.07.2010'))
end
it 'has :valid_to set to the beginning of next day after :valid_from' do
it 'has :valid_to set to the beginning of next day after :registered_at' do
expect(domain.valid_to).to eq(Time.zone.parse('06.07.2011 00:00'))
end
end

View file

@ -13,10 +13,8 @@ describe Invoice do
"Currency is missing",
"Due date is missing",
"Invoice items is missing",
"Invoice type is missing",
"Seller iban is missing",
"Seller name is missing",
"Vat prc is missing"
])
end
@ -52,20 +50,6 @@ describe Invoice do
@invoice.seller_address.should == 'Paldiski mnt. 123, Tallinn'
end
it 'should calculate sums correctly' do
@invoice = create(:invoice)
@invoice.vat_prc.should == BigDecimal.new('0.2')
@invoice.sum_without_vat.should == BigDecimal.new('300.0')
@invoice.vat.should == BigDecimal.new('60.0')
@invoice.sum.should == BigDecimal.new('360.0')
ii = @invoice.items.first
ii.item_sum_without_vat.should == BigDecimal.new('150.0')
ii = @invoice.items.last
ii.item_sum_without_vat.should == BigDecimal.new('150.0')
end
it 'should cancel overdue invoices' do
create(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 30.days)
Invoice.cancel_overdue_invoices

View file

@ -1,47 +0,0 @@
require 'rails_helper'
RSpec.describe 'EPP domain:delete' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
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>
<delete>
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>test.com</domain:name>
</domain:delete>
</delete>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
}
before :example do
login_as user
end
context 'when domain is not discarded' do
let!(:domain) { create(:domain, name: 'test.com') }
it 'returns epp code of 1001' do
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(1001)
end
end
context 'when domain is discarded' do
let!(:domain) { create(:domain_discarded, name: 'test.com') }
it 'returns epp code of 2105' do
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(2105)
end
end
end

View file

@ -1,42 +0,0 @@
require 'rails_helper'
RSpec.describe 'EPP domain:update' do
let(:registrar) { create(:registrar) }
let(:user) { create(:api_user_epp, registrar: registrar) }
let(:session_id) { create(:epp_session, user: user).session_id }
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>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>test.com</domain:name>
</domain:update>
</update>
</command>
</epp>
XML
}
before :example do
login_as user
end
context 'when domain is not discarded' do
let!(:domain) { create(:domain, name: 'test.com') }
it 'returns epp code of 1000' do
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(1000)
end
end
context 'when domain is discarded' do
let!(:domain) { create(:domain_discarded, name: 'test.com') }
it 'returns epp code of 2105' do
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
expect(response).to have_code_of(2105)
end
end
end