mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Merge branch 'master' into registry-475
# Conflicts: # config/locales/et.yml # db/structure.sql
This commit is contained in:
commit
cb4f2b5eeb
79 changed files with 825 additions and 815 deletions
|
@ -1,71 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Address do
|
||||
context 'about class' do
|
||||
it 'should have versioning enabled?' do
|
||||
Address.paper_trail_enabled_for_model?.should == true
|
||||
end
|
||||
|
||||
it 'should have custom log prexied table name for versions table' do
|
||||
AddressVersion.table_name.should == 'log_addresses'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid attribute' do
|
||||
before :all do
|
||||
@address = Address.new
|
||||
end
|
||||
|
||||
it 'should not be valid' do
|
||||
@address.valid?
|
||||
@address.errors.full_messages.should match_array([
|
||||
])
|
||||
end
|
||||
|
||||
it 'should not have any versions' do
|
||||
@address.versions.should == []
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid attributes' do
|
||||
before :all do
|
||||
@address = Fabricate(:address)
|
||||
end
|
||||
|
||||
it 'should be valid' do
|
||||
@address.valid?
|
||||
@address.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
it 'should be valid twice' do
|
||||
@address = Fabricate(:address)
|
||||
@address.valid?
|
||||
@address.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
it 'should have one version' do
|
||||
with_versioning do
|
||||
@address.versions.should == []
|
||||
@address.zip = 'New zip'
|
||||
@address.save
|
||||
@address.errors.full_messages.should match_array([])
|
||||
@address.versions.size.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: country issue
|
||||
# describe Address, '.extract_params' do
|
||||
# it 'returns params hash' do
|
||||
# Fabricate(:country, iso: 'EE')
|
||||
# ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: 'street1' } } }
|
||||
# expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
||||
# address_attributes: {
|
||||
# country_id: Country.find_by(iso: 'EE').id,
|
||||
# city: 'Village',
|
||||
# street: 'street1'
|
||||
# }
|
||||
# })
|
||||
# end
|
||||
# end
|
|
@ -354,7 +354,7 @@ describe Contact, '.destroy_orphans' do
|
|||
end
|
||||
end
|
||||
|
||||
RSpec.describe Contact, db: false do
|
||||
RSpec.describe Contact do
|
||||
it { is_expected.to alias_attribute(:kind, :ident_type) }
|
||||
|
||||
describe '::names' do
|
||||
|
@ -400,6 +400,16 @@ RSpec.describe Contact, db: false do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'registrar validation', db: false do
|
||||
let(:contact) { described_class.new }
|
||||
|
||||
it 'rejects absent' do
|
||||
contact.registrar = nil
|
||||
contact.validate
|
||||
expect(contact.errors).to have_key(:registrar)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'address validation', db: false do
|
||||
let(:contact) { described_class.new }
|
||||
subject(:errors) { contact.errors }
|
||||
|
@ -523,4 +533,66 @@ RSpec.describe Contact, db: false do
|
|||
specify { expect(contact.id_code).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#ident_country' do
|
||||
let(:contact) { described_class.new(ident_country_code: 'US') }
|
||||
|
||||
it 'returns ident country' do
|
||||
expect(contact.ident_country).to eq(Country.new('US'))
|
||||
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 }
|
||||
|
||||
it 'returns associated domains with roles' do
|
||||
domain = create(:domain, registrant: contact, name: 'test.com')
|
||||
domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact)
|
||||
domain.tech_domain_contacts << create(:tech_domain_contact, contact: contact)
|
||||
|
||||
contact.reload
|
||||
|
||||
expect(domain_names).to eq({ 'test.com' => %i[registrant admin_domain_contact tech_domain_contact].to_set })
|
||||
end
|
||||
|
||||
it 'returns unique roles' do
|
||||
domain = create(:domain, name: 'test.com')
|
||||
2.times { domain.admin_domain_contacts << create(:admin_domain_contact, contact: contact) }
|
||||
|
||||
contact.reload
|
||||
|
||||
expect(domain_names).to eq({ 'test.com' => %i[admin_domain_contact].to_set })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,16 +33,6 @@ RSpec.describe Domain do
|
|||
@domain = Domain.new
|
||||
end
|
||||
|
||||
it 'should not be valid' do
|
||||
@domain.valid?
|
||||
@domain.errors.full_messages.should match_array([
|
||||
"Admin domain contacts Admin contacts count must be between 1-10",
|
||||
"Period Period is not a number",
|
||||
"Registrant Registrant is missing",
|
||||
"Registrar Registrar is missing"
|
||||
])
|
||||
end
|
||||
|
||||
it 'should not have any versions' do
|
||||
@domain.versions.should == []
|
||||
end
|
||||
|
@ -599,10 +589,84 @@ RSpec.describe Domain do
|
|||
end
|
||||
end
|
||||
|
||||
RSpec.describe Domain, db: false do
|
||||
RSpec.describe Domain do
|
||||
it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) }
|
||||
it { is_expected.to alias_attribute(:outzone_time, :outzone_at) }
|
||||
|
||||
describe 'registrar validation', db: false do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
it 'rejects absent' do
|
||||
domain.registrar = nil
|
||||
domain.validate
|
||||
expect(domain.errors).to have_key(:registrar)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'registrant validation', db: false do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
it 'rejects absent' do
|
||||
domain.registrant = nil
|
||||
domain.validate
|
||||
expect(domain.errors).to have_key(:registrant)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'period validation', db: false do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
it 'rejects absent' do
|
||||
domain.period = nil
|
||||
domain.validate
|
||||
expect(domain.errors).to have_key(:period)
|
||||
end
|
||||
|
||||
it 'rejects fractional' do
|
||||
domain.period = 1.1
|
||||
domain.validate
|
||||
expect(domain.errors).to have_key(:period)
|
||||
end
|
||||
|
||||
it 'accepts integer' do
|
||||
domain.period = 1
|
||||
domain.validate
|
||||
expect(domain.errors).to_not have_key(:period)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin contact count validation' do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
before :example do
|
||||
Setting.admin_contacts_min_count = 1
|
||||
Setting.admin_contacts_max_count = 2
|
||||
end
|
||||
|
||||
it 'rejects less than min' do
|
||||
domain.validate
|
||||
expect(domain.errors).to have_key(:admin_domain_contacts)
|
||||
end
|
||||
|
||||
it 'rejects more than max' do
|
||||
(Setting.admin_contacts_max_count + 1).times { domain.admin_domain_contacts << build(:admin_domain_contact) }
|
||||
domain.validate
|
||||
expect(domain.errors).to have_key(:admin_domain_contacts)
|
||||
end
|
||||
|
||||
it 'accepts min' do
|
||||
Setting.admin_contacts_min_count.times { domain.admin_domain_contacts << build(:admin_domain_contact) }
|
||||
domain.validate
|
||||
expect(domain.errors).to_not have_key(:admin_domain_contacts)
|
||||
end
|
||||
|
||||
it 'accepts max' do
|
||||
Setting.admin_contacts_max_count.times { domain.admin_domain_contacts << build(:admin_domain_contact) }
|
||||
domain.validate
|
||||
expect(domain.errors).to_not have_key(:admin_domain_contacts)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'nameserver validation', db: true do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue