mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 07:52:04 +02:00
Merge branch 'improve-registrar' into registry-267
# Conflicts: # db/schema-read-only.rb # db/structure.sql
This commit is contained in:
commit
5c6a0034f6
15 changed files with 316 additions and 22 deletions
|
@ -361,6 +361,8 @@ describe Contact, '.destroy_orphans' do
|
|||
end
|
||||
|
||||
RSpec.describe Contact, db: false do
|
||||
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
||||
|
||||
describe '::names' do
|
||||
before :example do
|
||||
expect(described_class).to receive(:pluck).with(:name).and_return('names')
|
||||
|
@ -463,4 +465,20 @@ RSpec.describe Contact, db: false do
|
|||
expect(address_removed).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reg_no' do
|
||||
subject(:reg_no) { contact.reg_no }
|
||||
|
||||
context 'when contact is legal entity' do
|
||||
let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') }
|
||||
|
||||
specify { expect(reg_no).to eq('1234') }
|
||||
end
|
||||
|
||||
context 'when contact is private entity' do
|
||||
let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') }
|
||||
|
||||
specify { expect(reg_no).to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
71
spec/models/legal_documents_spec.rb
Normal file
71
spec/models/legal_documents_spec.rb
Normal file
|
@ -0,0 +1,71 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe LegalDocument do
|
||||
context 'tasks' do
|
||||
it 'make files uniq' do
|
||||
Fabricate(:zonefile_setting, origin: 'ee')
|
||||
Fabricate(:zonefile_setting, origin: 'pri.ee')
|
||||
Fabricate(:zonefile_setting, origin: 'med.ee')
|
||||
Fabricate(:zonefile_setting, origin: 'fie.ee')
|
||||
Fabricate(:zonefile_setting, origin: 'com.ee')
|
||||
LegalDocument.explicitly_write_file = true
|
||||
PaperTrail.enabled = true
|
||||
|
||||
domain = Fabricate(:domain)
|
||||
domain2 = Fabricate(:domain)
|
||||
legals = []
|
||||
legals << original = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << copy = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << skipping_as_different_domain = domain2.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << skipping_as_different = domain.legal_documents.create!(body: Base64.encode64('D' * 4.kilobytes))
|
||||
legals << skipping_as_no_checksum = domain.legal_documents.create!(checksum: nil, body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << skipping_as_no_checksum2 = domain.legal_documents.create!(checksum: "", body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << registrant_copy = domain.registrant.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << registrant_skipping_as_different = domain.registrant.legal_documents.create!(body: Base64.encode64('Q' * 4.kilobytes))
|
||||
legals << tech_copy = domain.tech_contacts.first.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << tech_skipping_as_different = domain.tech_contacts.first.legal_documents.create!(body: Base64.encode64('W' * 4.kilobytes))
|
||||
legals << admin_copy = domain.admin_contacts.first.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
legals << admin_skipping_as_different = domain.admin_contacts.first.legal_documents.create!(body: Base64.encode64('E' * 4.kilobytes))
|
||||
legals << new_second_tech_contact = domain2.tech_contacts.first.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes))
|
||||
domain.tech_contacts << domain2.tech_contacts.first
|
||||
|
||||
|
||||
# writing nesting to history
|
||||
domain.update(updated_at: Time.now)
|
||||
domain2.update(updated_at: Time.now)
|
||||
domain.reload
|
||||
|
||||
skipping_as_no_checksum.update_columns(checksum: nil)
|
||||
skipping_as_no_checksum2.update_columns(checksum: "")
|
||||
skipping_as_no_checksum.reload
|
||||
skipping_as_no_checksum2.reload
|
||||
skipping_as_no_checksum.path.should_not == skipping_as_no_checksum2.path
|
||||
|
||||
skipping_as_no_checksum.checksum.should == nil
|
||||
skipping_as_no_checksum2.checksum.should == ""
|
||||
original.checksum.should == copy.checksum
|
||||
original.checksum.should_not == skipping_as_different.checksum
|
||||
domain.tech_contacts.count.should == 2
|
||||
|
||||
LegalDocument.remove_duplicates
|
||||
LegalDocument.remove_duplicates
|
||||
LegalDocument.remove_duplicates
|
||||
legals.each(&:reload)
|
||||
|
||||
skipping_as_no_checksum.path.should_not be(skipping_as_no_checksum2.path)
|
||||
original.path.should_not == skipping_as_different.path
|
||||
original.path.should_not == skipping_as_different_domain.path
|
||||
original.path.should_not == registrant_skipping_as_different.path
|
||||
original.path.should_not == tech_skipping_as_different.path
|
||||
original.path.should_not == admin_skipping_as_different.path
|
||||
original.path.should == copy.path
|
||||
original.path.should == registrant_copy.path
|
||||
original.path.should == tech_copy.path
|
||||
original.path.should == admin_copy.path
|
||||
|
||||
original.path.should == new_second_tech_contact.path
|
||||
skipping_as_different_domain.path.should_not == new_second_tech_contact.path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
67
spec/models/whois_record_spec.rb
Normal file
67
spec/models/whois_record_spec.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe WhoisRecord do
|
||||
describe '::generate_json', db: false do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant) }
|
||||
let(:domain) { FactoryGirl.build_stubbed(:domain, registrant: registrant) }
|
||||
let(:whois_record) { described_class.new }
|
||||
subject(:generated_json) { whois_record.generate_json }
|
||||
|
||||
before do
|
||||
allow(whois_record).to receive(:domain).and_return(domain)
|
||||
end
|
||||
|
||||
it 'generates registrant kind' do
|
||||
expect(registrant).to receive(:kind).and_return('test kind')
|
||||
expect(generated_json[:registrant_kind]).to eq('test kind')
|
||||
end
|
||||
|
||||
describe 'reg no' do
|
||||
subject(:reg_no) { generated_json[:registrant_reg_no] }
|
||||
|
||||
before do
|
||||
allow(registrant).to receive(:reg_no).and_return('test reg no')
|
||||
end
|
||||
|
||||
context 'when registrant is legal entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) }
|
||||
|
||||
it 'is present' do
|
||||
expect(reg_no).to eq('test reg no')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when registrant is private entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) }
|
||||
|
||||
it 'is absent' do
|
||||
expect(reg_no).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'country code' do
|
||||
subject(:country_code) { generated_json[:registrant_ident_country_code] }
|
||||
|
||||
before do
|
||||
allow(registrant).to receive(:ident_country_code).and_return('test country code')
|
||||
end
|
||||
|
||||
context 'when registrant is legal entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) }
|
||||
|
||||
it 'is present' do
|
||||
expect(country_code).to eq('test country code')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when registrant is private entity' do
|
||||
let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) }
|
||||
|
||||
it 'is absent' do
|
||||
expect(country_code).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue