Merge branch 'master' into registry-623

# Conflicts:
#	db/structure.sql
This commit is contained in:
Artur Beljajev 2018-03-08 13:04:11 +02:00
commit ffc32b66de
72 changed files with 1004 additions and 932 deletions

View file

@ -76,10 +76,6 @@ RSpec.describe Contact do
end
end
it 'should not have relation with domains' do
@contact.domains_present?.should == false
end
it 'should not overwrite code' do
old_code = @contact.code
@contact.code = 'CID:REG1:should-not-overwrite-old-code-12345'
@ -417,36 +413,6 @@ RSpec.describe Contact do
end
end
describe '#used?' do
context 'when used as registrant' do
let(:registrant) { create(:registrant) }
before :example do
create(:domain, registrant: registrant)
registrant.reload
end
specify { expect(registrant).to be_used }
end
context 'when used as contact' do
let(:contact) { create(:contact) }
before :example do
domain = create(:domain)
domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact)
contact.reload
end
specify { expect(contact).to be_used }
end
context 'when not used' do
let(:contact) { create(:contact) }
specify { expect(contact).to_not be_used }
end
end
describe '#domain_names_with_roles' do
let(:contact) { create(:registrant) }
subject(:domain_names) { contact.domain_names_with_roles }

View file

@ -568,8 +568,8 @@ RSpec.describe Domain do
with_versioning do
context 'when saved' do
before(:each) do
domain = create(:domain)
domain.nameservers << create(:nameserver)
domain = create(:domain, nameservers_attributes: [attributes_for(:nameserver),
attributes_for(:nameserver)])
end
it 'creates domain version' do
@ -660,7 +660,7 @@ RSpec.describe Domain do
end
describe 'nameserver validation', db: true do
let(:domain) { described_class.new }
let(:domain) { described_class.new(name: 'whatever.test') }
it 'rejects less than min' do
Setting.ns_min_count = 2

View file

@ -1,125 +0,0 @@
require 'rails_helper'
describe Nameserver do
before :example do
Setting.ds_algorithm = 2
Setting.ds_data_allowed = true
Setting.ds_data_with_key_allowed = true
Setting.key_data_allowed = true
Setting.dnskeys_min_count = 0
Setting.dnskeys_max_count = 9
Setting.ns_min_count = 2
Setting.ns_max_count = 11
Setting.transfer_wait_time = 0
Setting.admin_contacts_min_count = 1
Setting.admin_contacts_max_count = 10
Setting.tech_contacts_min_count = 0
Setting.tech_contacts_max_count = 10
Setting.client_side_status_editing_enabled = true
create(:zone, origin: 'ee')
end
context 'with invalid attribute' do
before :example do
@nameserver = Nameserver.new
end
it 'should not have any versions' do
@nameserver.versions.should == []
end
end
context 'with valid attributes' do
before :example do
@nameserver = create(:nameserver)
end
it 'should be valid' do
@nameserver.valid?
@nameserver.errors.full_messages.should match_array([])
end
it 'should be valid twice' do
@nameserver = create(:nameserver)
@nameserver.valid?
@nameserver.errors.full_messages.should match_array([])
end
it 'should have one version' do
with_versioning do
@nameserver.versions.should == []
@nameserver.hostname = 'hostname.ee'
@nameserver.save
@nameserver.errors.full_messages.should match_array([])
@nameserver.versions.size.should == 1
end
end
context 'with many nameservers' do
before :example do
@api_user = create(:api_user)
@domain_1 = create(:domain, nameservers: [
create(:nameserver, hostname: 'ns1.ns.ee'),
create(:nameserver, hostname: 'ns2.ns.ee'),
create(:nameserver, hostname: 'ns2.test.ee')
], registrar: @api_user.registrar)
@domain_2 = create(:domain, nameservers: [
create(:nameserver, hostname: 'ns1.ns.ee'),
create(:nameserver, hostname: 'ns2.ns.ee'),
create(:nameserver, hostname: 'ns3.test.ee')
], registrar: @api_user.registrar)
@domain_3 = create(:domain, nameservers: [
create(:nameserver, hostname: 'ns1.ns.ee'),
create(:nameserver, hostname: 'ns2.ns.ee'),
create(:nameserver, hostname: 'ns3.test.ee')
])
end
it 'should replace hostname ends' do
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'ns.ee', 'test.ee')
res.should == 'replaced_some'
@api_user.registrar.nameservers.where("hostname LIKE '%test.ee'").count.should == 4
@domain_1.nameservers.pluck(:hostname).should include('ns1.ns.ee', 'ns2.ns.ee', 'ns2.test.ee')
@domain_2.nameservers.pluck(:hostname).should include('ns1.test.ee', 'ns2.test.ee', 'ns3.test.ee')
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'test.ee', 'testing.ee')
res.should == 'replaced_all'
@api_user.registrar.nameservers.where("hostname LIKE '%testing.ee'").count.should == 4
@domain_1.nameservers.pluck(:hostname).should include('ns1.ns.ee', 'ns2.ns.ee', 'ns2.testing.ee')
@domain_2.nameservers.pluck(:hostname).should include('ns1.testing.ee', 'ns2.testing.ee', 'ns3.testing.ee')
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'ns.ee', 'test.ee')
res.should == 'replaced_all'
@api_user.registrar.nameservers.where("hostname LIKE '%test.ee'").count.should == 2
@domain_1.nameservers.pluck(:hostname).should include('ns1.test.ee', 'ns2.test.ee', 'ns2.testing.ee')
@domain_2.nameservers.pluck(:hostname).should include('ns1.testing.ee', 'ns2.testing.ee', 'ns3.testing.ee')
@domain_3.nameservers.pluck(:hostname).should include('ns1.ns.ee', 'ns2.ns.ee', 'ns3.test.ee')
res = Nameserver.replace_hostname_ends(@api_user.registrar.domains, 'xcv.ee', 'test.ee')
res.should == 'replaced_none'
end
end
end
end
RSpec.describe Nameserver do
describe '::hostnames', db: false do
before :example do
expect(described_class).to receive(:pluck).with(:hostname).and_return('hostnames')
end
it 'returns names' do
expect(described_class.hostnames).to eq('hostnames')
end
end
end