mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 11:38:30 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
02e313db46
41 changed files with 237 additions and 695 deletions
|
@ -11,8 +11,7 @@ describe 'EPP Contact', epp: true do
|
|||
Fabricate(:epp_user)
|
||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate(:dnskeys_setting_group)
|
||||
create_settings
|
||||
end
|
||||
|
||||
context 'create command' do
|
||||
|
|
|
@ -6,14 +6,12 @@ describe 'EPP Domain', epp: true do
|
|||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||
let(:zone) { Fabricate(:registrar) }
|
||||
|
||||
before(:each) { create_settings }
|
||||
|
||||
context 'with valid user' do
|
||||
before(:each) do
|
||||
Fabricate(:epp_user, username: 'zone', registrar: zone)
|
||||
Fabricate(:epp_user, username: 'elkdata', registrar: elkdata)
|
||||
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate(:domain_statuses_setting_group)
|
||||
Fabricate(:dnskeys_setting_group)
|
||||
end
|
||||
|
||||
it 'returns error if contact does not exists' do
|
||||
|
@ -36,7 +34,6 @@ describe 'EPP Domain', epp: true do
|
|||
let(:domain) { Domain.first }
|
||||
|
||||
before(:each) do
|
||||
Fabricate(:domain_general_setting_group)
|
||||
Fabricate(:domain, name: 'example.ee', registrar: zone)
|
||||
end
|
||||
|
||||
|
@ -65,8 +62,7 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
expect(domain.registrar).to eq(elkdata)
|
||||
|
||||
s = Setting.find_by(code: 'transfer_wait_time')
|
||||
s.update(value: 1)
|
||||
Setting.transfer_wait_time = 1
|
||||
|
||||
domain.reload
|
||||
pw = domain.auth_info
|
||||
|
@ -209,8 +205,8 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
expect(key.ds_alg).to eq(3)
|
||||
expect(key.ds_key_tag).to_not be_blank
|
||||
sg = SettingGroup.dnskeys
|
||||
expect(key.ds_digest_type).to eq(sg.setting(Setting::DS_ALGORITHM).value.to_i)
|
||||
|
||||
expect(key.ds_digest_type).to eq(Setting.ds_algorithm)
|
||||
expect(key.flags).to eq(257)
|
||||
expect(key.protocol).to eq(3)
|
||||
expect(key.alg).to eq(5)
|
||||
|
@ -297,7 +293,7 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
response = epp_request(xml, :xml)
|
||||
expect(response[:result_code]).to eq('2004')
|
||||
expect(response[:msg]).to eq('Nameservers count must be between 1-13')
|
||||
expect(response[:msg]).to eq('Nameservers count must be between 2-11')
|
||||
end
|
||||
|
||||
it 'returns error when invalid nameservers are present' do
|
||||
|
@ -391,7 +387,7 @@ describe 'EPP Domain', epp: true do
|
|||
key_1 = d.dnskeys[0]
|
||||
expect(key_1.ds_key_tag).to_not be_blank
|
||||
expect(key_1.ds_alg).to eq(3)
|
||||
expect(key_1.ds_digest_type).to eq(SettingGroup.dnskeys.setting(Setting::DS_ALGORITHM).value.to_i)
|
||||
expect(key_1.ds_digest_type).to eq(Setting.ds_algorithm)
|
||||
|
||||
expect(d.dnskeys.pluck(:flags)).to match_array([257, 0, 256])
|
||||
expect(d.dnskeys.pluck(:protocol)).to match_array([3, 3, 3])
|
||||
|
@ -484,9 +480,7 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'validated dnskeys count' do
|
||||
s = Setting.find_by(code: 'dnskeys_max_count')
|
||||
s.value = 1
|
||||
s.save
|
||||
Setting.dnskeys_max_count = 1
|
||||
|
||||
xml = domain_create_xml({}, {
|
||||
_other: [
|
||||
|
@ -572,10 +566,7 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'prohibits dsData with key' do
|
||||
sg = SettingGroup.dnskeys
|
||||
s = sg.setting(Setting::ALLOW_DS_DATA_WITH_KEYS)
|
||||
s.value = 0
|
||||
s.save
|
||||
Setting.ds_data_with_key_allowed = false
|
||||
|
||||
xml = domain_create_xml({}, {
|
||||
_other: [
|
||||
|
@ -600,10 +591,7 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'prohibits dsData' do
|
||||
sg = SettingGroup.dnskeys
|
||||
s = sg.setting(Setting::ALLOW_DS_DATA)
|
||||
s.value = 0
|
||||
s.save
|
||||
Setting.ds_data_allowed = false
|
||||
|
||||
xml = domain_create_xml({}, {
|
||||
_other: [
|
||||
|
@ -628,10 +616,7 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
it 'prohibits keyData' do
|
||||
sg = SettingGroup.dnskeys
|
||||
s = sg.setting(Setting::ALLOW_KEY_DATA)
|
||||
s.value = 0
|
||||
s.save
|
||||
Setting.key_data_allowed = false
|
||||
|
||||
xml = domain_create_xml({}, {
|
||||
_other: [
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
Fabricator(:setting) do
|
||||
code 'ns_min_count'
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
Fabricator(:setting_group) do
|
||||
code 'domain_validation'
|
||||
settings do
|
||||
[
|
||||
Fabricate(:setting, code: 'ns_min_count', value: 1),
|
||||
Fabricate(:setting, code: 'ns_max_count', value: 13)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:domain_validation_setting_group, from: :setting_group) do
|
||||
code 'domain_validation'
|
||||
settings do
|
||||
[
|
||||
Fabricate(:setting, code: 'ns_min_count', value: 1),
|
||||
Fabricate(:setting, code: 'ns_max_count', value: 13),
|
||||
Fabricate(:setting, code: 'dnskeys_min_count', value: 0),
|
||||
Fabricate(:setting, code: 'dnskeys_max_count', value: 9)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:domain_statuses_setting_group, from: :setting_group) do
|
||||
code 'domain_statuses'
|
||||
settings do
|
||||
[
|
||||
Fabricate(:setting, code: 'client_hold', value: 'clientHold'),
|
||||
Fabricate(:setting, code: 'client_update_prohibited', value: 'clientUpdateProhibited')
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:domain_general_setting_group, from: :setting_group) do
|
||||
code 'domain_general'
|
||||
settings do
|
||||
[
|
||||
Fabricate(:setting, code: 'transfer_wait_time', value: '0')
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:dnskeys_setting_group, from: :setting_group) do
|
||||
code 'dnskeys'
|
||||
settings do
|
||||
[
|
||||
Fabricate(:setting, code: Setting::DS_ALGORITHM, value: 2),
|
||||
Fabricate(:setting, code: Setting::ALLOW_DS_DATA, value: 1),
|
||||
Fabricate(:setting, code: Setting::ALLOW_DS_DATA_WITH_KEYS, value: 1),
|
||||
Fabricate(:setting, code: Setting::ALLOW_KEY_DATA, value: 1)
|
||||
]
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Contact management', type: :feature do
|
||||
# background do
|
||||
# end
|
||||
|
||||
before(:each) do
|
||||
Fabricate(:user, country: Fabricate(:country, iso: 'EE'), admin: false, username: 'zone')
|
||||
visit login_path
|
||||
click_on 'ID card (zone)'
|
||||
end
|
||||
|
||||
scenario 'User sees contacts', js: true do
|
||||
Fabricate(:contact, registrar: Registrar.first)
|
||||
Fabricate(:contact, registrar: Registrar.first)
|
||||
visit client_contacts_path
|
||||
expect(page).to have_text(Contact.first.name)
|
||||
expect(page).to have_text(Contact.second.name)
|
||||
end
|
||||
|
||||
scenario 'User creates contact', js: true do
|
||||
visit client_contacts_path
|
||||
click_on 'Create new contact'
|
||||
fill_in('Name', with: 'John Doe The Third')
|
||||
fill_in('Email', with: 'john@doe.eu')
|
||||
fill_in('Phone', with: '+123.3213123')
|
||||
fill_in('Ident', with: '312313')
|
||||
click_on 'Save'
|
||||
|
||||
expect(current_path).to eq client_contact_path(Contact.first)
|
||||
|
||||
expect(page).to have_text('Contact added!')
|
||||
expect(page).to have_text('Contact details')
|
||||
expect(page).to have_text('John Doe The Third')
|
||||
|
||||
expect(Contact.first.registrar).to eq Registrar.first
|
||||
end
|
||||
end
|
|
@ -1,124 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Domain management', type: :feature do
|
||||
background do
|
||||
Fabricate(:registrar)
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate.times(4, :domain)
|
||||
end
|
||||
|
||||
scenario 'User sees domains', js: true do
|
||||
visit root_path
|
||||
click_on 'Domains'
|
||||
|
||||
Domain.all.each do |x|
|
||||
expect(page).to have_link(x)
|
||||
expect(page).to have_link(x.registrar)
|
||||
expect(page).to have_link(x.owner_contact)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'User adds a domain', js: true do
|
||||
visit admin_domains_path
|
||||
click_on 'Add'
|
||||
fill_in('Domain name', with: 'example.ee')
|
||||
fill_in('Period', with: 1)
|
||||
fill_in('Registrar', with: 'zone', fill_options: { blur: false })
|
||||
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
|
||||
# expect(page).to have_text('Zone Media OÜ (10577829)')
|
||||
# click_on('Zone Media OÜ (10577829)')
|
||||
# expect(find_field('Registrar').value).to eq('Zone Media OÜ (10577829)')
|
||||
|
||||
# temporary solution:
|
||||
|
||||
page.execute_script("$('#domain_registrar_id').val('1')")
|
||||
|
||||
c = Contact.first
|
||||
|
||||
fill_in('Registrant', with: c.code, fill_options: { blur: false })
|
||||
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
|
||||
# expect(page).to have_text(c.code)
|
||||
# click_on(c.code)
|
||||
# expect(find_field('Registrar').value).to eq(c.code)
|
||||
|
||||
# temporary solution:
|
||||
page.execute_script("$('#domain_owner_contact_id').val('1')")
|
||||
|
||||
click_on('Save')
|
||||
|
||||
expect(page).to have_text('Domain details')
|
||||
expect(page).to have_text('example.ee')
|
||||
expect(page).to have_link('Zone Media OÜ')
|
||||
expect(page).to have_link(c.name, count: 3)
|
||||
expect(page).to have_text(c.code)
|
||||
expect(page).to have_text(c.ident)
|
||||
expect(page).to have_text(c.email)
|
||||
expect(page).to have_text(c.phone)
|
||||
expect(page).to have_text('Nameservers count must be between 1-13')
|
||||
end
|
||||
|
||||
scenario 'User adds nameserver to domain' do
|
||||
d = Domain.first
|
||||
visit admin_domain_path(d)
|
||||
|
||||
within('#nameservers') { click_on 'Add' }
|
||||
|
||||
fill_in('Hostname', with: 'ns1.example.ee')
|
||||
fill_in('Ipv4', with: '192.168.1.1')
|
||||
fill_in('Ipv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
expect(page).to have_text('Nameserver added!')
|
||||
|
||||
within('#nameservers') do
|
||||
expect(page).to have_link('ns1.example.ee')
|
||||
expect(page).to have_text('192.168.1.1')
|
||||
expect(page).to have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'User adds status to domain' do
|
||||
d = Domain.first
|
||||
visit admin_domain_path(d)
|
||||
|
||||
within('#domain_statuses') { click_on 'Add' }
|
||||
|
||||
fill_in('Description', with: 'All is well.')
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
expect(page).to have_text('Status added!')
|
||||
|
||||
within('#domain_statuses') do
|
||||
expect(page).to have_text('ok')
|
||||
expect(page).to have_text('All is well.')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'User adds technical contact', js: true do
|
||||
d = Domain.first
|
||||
visit admin_domain_path(d)
|
||||
|
||||
within('#tech_contacts') { click_on 'Add' }
|
||||
|
||||
c = Contact.last
|
||||
fill_in('Contact', with: c.code, fill_options: { blur: false })
|
||||
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
|
||||
# expect(page).to have_text(c.code)
|
||||
# click_on(c.code)
|
||||
# expect(find_field('Tech contact').value).to eq(c.code)
|
||||
|
||||
# temporary solution:
|
||||
page.execute_script("$('#domain_contact_contact_id').val('#{c.id}')")
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
expect(page).to have_text('Contact added!')
|
||||
|
||||
within('#tech_contacts') do
|
||||
expect(page).to have_link(c.name)
|
||||
expect(page).to have_text(c.email)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,126 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Domain transfer', type: :feature do
|
||||
let(:elkdata) { Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' }) }
|
||||
let(:zone) { Fabricate(:registrar) }
|
||||
let(:zone_user) { Fabricate(:user, registrar: zone, username: 'zone', admin: false, identity_code: '37810013087') }
|
||||
let(:elkdata_user) do
|
||||
Fabricate(:user, registrar: elkdata, username: 'elkdata', admin: false, identity_code: '37810013261')
|
||||
end
|
||||
|
||||
background do
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate(:domain_general_setting_group)
|
||||
Fabricate(:dnskeys_setting_group)
|
||||
Fabricate(:domain, registrar: zone)
|
||||
end
|
||||
|
||||
scenario 'Registrar requests transfer on own domain', js: true do
|
||||
sign_in zone_user
|
||||
click_on 'Domains'
|
||||
click_on 'Domain transfers list'
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
fill_in 'Domain name', with: 'false'
|
||||
click_on 'Request domain transfer'
|
||||
expect(page).to have_text('Domain was not found!')
|
||||
|
||||
d = Domain.first
|
||||
fill_in 'Domain name', with: d.name
|
||||
click_on 'Request domain transfer'
|
||||
expect(page).to have_text('Password invalid!')
|
||||
|
||||
fill_in 'Domain password', with: d.auth_info
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
expect(page).to have_text('Domain already belongs to the querying registrar')
|
||||
end
|
||||
|
||||
scenario 'Other registrar requests transfer with 0 wait time' do
|
||||
sign_in elkdata_user
|
||||
d = Domain.first
|
||||
visit client_domains_path
|
||||
expect(page).to_not have_link(d.name)
|
||||
|
||||
visit new_client_domain_transfer_path
|
||||
fill_in 'Domain name', with: d.name
|
||||
fill_in 'Domain password', with: d.auth_info
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
expect(page).to have_text('Domain transfer approved!')
|
||||
expect(page).to have_text('serverApproved')
|
||||
|
||||
visit client_domains_path
|
||||
expect(page).to have_link(d.name)
|
||||
end
|
||||
|
||||
scenario 'Other registrar requests transfer with 1 wait time' do
|
||||
s = Setting.find_by(code: 'transfer_wait_time')
|
||||
s.value = 1
|
||||
s.save
|
||||
|
||||
sign_in elkdata_user
|
||||
d = Domain.first
|
||||
visit client_domains_path
|
||||
expect(page).to_not have_link(d.name)
|
||||
|
||||
visit new_client_domain_transfer_path
|
||||
fill_in 'Domain name', with: d.name
|
||||
fill_in 'Domain password', with: d.auth_info
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
expect(page).to have_text('Domain transfer requested!')
|
||||
expect(page).to have_text('pending')
|
||||
|
||||
visit new_client_domain_transfer_path
|
||||
fill_in 'Domain name', with: d.name
|
||||
fill_in 'Domain password', with: d.auth_info
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
expect(page).to have_text('Domain transfer requested!')
|
||||
expect(page).to have_text('pending')
|
||||
|
||||
visit client_domains_path
|
||||
expect(page).to_not have_link(d.name)
|
||||
end
|
||||
|
||||
scenario 'Domain owner approves request' do
|
||||
s = Setting.find_by(code: 'transfer_wait_time')
|
||||
s.value = 1
|
||||
s.save
|
||||
|
||||
d = Domain.first
|
||||
d.domain_transfers.create(
|
||||
status: DomainTransfer::PENDING,
|
||||
transfer_requested_at: Time.zone.now,
|
||||
transfer_to: elkdata,
|
||||
transfer_from: zone
|
||||
)
|
||||
|
||||
sign_in elkdata_user
|
||||
visit new_client_domain_transfer_path
|
||||
fill_in 'Domain name', with: d.name
|
||||
fill_in 'Domain password', with: d.auth_info
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
expect(page).to have_text('Domain transfer requested!')
|
||||
expect(page).to_not have_button('Approve')
|
||||
|
||||
sign_in zone_user
|
||||
|
||||
visit new_client_domain_transfer_path
|
||||
fill_in 'Domain name', with: d.name
|
||||
fill_in 'Domain password', with: d.auth_info
|
||||
click_on 'Request domain transfer'
|
||||
|
||||
expect(page).to have_link('Approve')
|
||||
|
||||
click_on 'Approve'
|
||||
expect(page).to have_text('Domain transfer approved!')
|
||||
expect(page).to have_text('clientApproved')
|
||||
|
||||
sign_in elkdata_user
|
||||
visit client_domains_path
|
||||
expect(page).to have_link(d.name)
|
||||
end
|
||||
end
|
|
@ -5,9 +5,9 @@ feature 'Sessions', type: :feature do
|
|||
let(:zone) { Fabricate(:registrar) }
|
||||
|
||||
background do
|
||||
Fabricate(:user, registrar: zone, username: 'elkdata', identity_code: '37810013261')
|
||||
create_settings
|
||||
Fabricate(:user, registrar: nil, identity_code: '37810013261')
|
||||
Fabricate(:user, registrar: zone, username: 'zone', admin: false, identity_code: '37810013087')
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate.times(2, :domain, registrar: zone)
|
||||
Fabricate.times(2, :domain, registrar: elkdata)
|
||||
end
|
||||
|
|
|
@ -1,37 +1,30 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Setting management', type: :feature do
|
||||
background { Fabricate(:domain_validation_setting_group) }
|
||||
let(:zone) { Fabricate(:registrar) }
|
||||
let(:zone_user) { Fabricate(:user, registrar: zone, username: 'zone', admin: true, identity_code: '37810013087') }
|
||||
|
||||
scenario 'User changes a setting', js: true do
|
||||
visit root_path
|
||||
background { create_settings }
|
||||
|
||||
# This ensures javascript works correctly
|
||||
expect(page).to have_no_link 'Setting groups'
|
||||
click_on 'Settings'
|
||||
expect(page).to have_link 'Setting groups'
|
||||
scenario 'User changes a setting' do
|
||||
sign_in zone_user
|
||||
visit admin_settings_path
|
||||
|
||||
click_on 'Setting groups'
|
||||
expect(page).to have_text('Domain validation')
|
||||
click_on 'Edit settings'
|
||||
expect(page).to have_text('Nameserver minimum count')
|
||||
expect(page).to have_text('Nameserver maximum count')
|
||||
val_min = find_field('_settings_ns_min_count').value
|
||||
val_max = find_field('_settings_ns_max_count').value
|
||||
|
||||
val_min = find_field('Nameserver minimum count').value
|
||||
val_max = find_field('Nameserver maximum count').value
|
||||
expect(val_min).to eq('2')
|
||||
expect(val_max).to eq('11')
|
||||
|
||||
expect(val_min).to eq('1')
|
||||
expect(val_max).to eq('13')
|
||||
fill_in '_settings_ns_min_count', with: 0
|
||||
fill_in '_settings_ns_max_count', with: 10
|
||||
|
||||
fill_in('Nameserver minimum count', with: '3')
|
||||
fill_in('Nameserver maximum count', with: '10')
|
||||
click_button 'Save'
|
||||
|
||||
click_on 'Save'
|
||||
val_min = find_field('_settings_ns_min_count').value
|
||||
val_max = find_field('_settings_ns_max_count').value
|
||||
|
||||
val_min = find_field('Nameserver minimum count').value
|
||||
val_max = find_field('Nameserver maximum count').value
|
||||
|
||||
expect(val_min).to eq('3')
|
||||
expect(val_min).to eq('0')
|
||||
expect(val_max).to eq('10')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,8 @@ describe Address, '.extract_params' do
|
|||
ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: %w(street1 street2) } } }
|
||||
expect(Address.extract_attributes(ph[:postalInfo])).to eq({
|
||||
address_attributes: {
|
||||
city: 'Village',
|
||||
country_id: 1,
|
||||
city: 'Village',
|
||||
street: 'street1',
|
||||
street2: 'street2'
|
||||
}
|
||||
|
|
|
@ -50,8 +50,7 @@ describe Contact, '#relations_with_domain?' do
|
|||
|
||||
context 'with relation' do
|
||||
before(:each) do
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate(:dnskeys_setting_group)
|
||||
create_settings
|
||||
Fabricate(:domain)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ require 'rails_helper'
|
|||
|
||||
describe Dnskey do
|
||||
before(:each) do
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate(:dnskeys_setting_group)
|
||||
create_settings
|
||||
end
|
||||
|
||||
it { should belong_to(:domain) }
|
||||
|
|
|
@ -11,8 +11,7 @@ describe Domain do
|
|||
|
||||
context 'with sufficient settings' do
|
||||
before(:each) do
|
||||
Fabricate(:domain_validation_setting_group)
|
||||
Fabricate(:dnskeys_setting_group)
|
||||
create_settings
|
||||
end
|
||||
|
||||
it 'validates domain name' do
|
||||
|
@ -51,20 +50,13 @@ describe Domain do
|
|||
period: ['is not a number'],
|
||||
owner_contact: ['Registrant is missing'],
|
||||
admin_contacts: ['Admin contacts count must be between 1 - infinity'],
|
||||
nameservers: ['Nameservers count must be between 1-13'],
|
||||
nameservers: ['Nameservers count must be between 2-11'],
|
||||
registrar: ['Registrar is missing'],
|
||||
period: ['Period is not a number']
|
||||
})
|
||||
|
||||
sg = SettingGroup.domain_validation
|
||||
min = sg.setting(:ns_min_count)
|
||||
max = sg.setting(:ns_max_count)
|
||||
|
||||
min.value = 2
|
||||
min.save
|
||||
|
||||
max.value = 7
|
||||
max.save
|
||||
Setting.ns_min_count = 2
|
||||
Setting.ns_max_count = 7
|
||||
|
||||
expect(d.valid?).to be false
|
||||
expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe SettingGroup do
|
||||
it { should have_many(:settings) }
|
||||
end
|
|
@ -1,21 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Setting do
|
||||
it { should belong_to(:setting_group) }
|
||||
|
||||
it 'validates code uniqueness' do
|
||||
sg = Fabricate(:setting_group)
|
||||
sg.settings.build(code: 'this_is_code')
|
||||
expect(sg.save).to be true
|
||||
|
||||
sg.settings.build(code: 'this_is_code')
|
||||
expect(sg.save).to be false
|
||||
err = sg.settings.last.errors[:code].first
|
||||
expect(err).to eq('Code already exists')
|
||||
|
||||
sg_2 = Fabricate(:setting_group, code: 'domain_statuses')
|
||||
|
||||
sg_2.settings.build(code: 'this_is_code')
|
||||
expect(sg_2.save).to be true
|
||||
it 'returns value' do
|
||||
create_settings
|
||||
expect(Setting.ns_min_count).to eq(2)
|
||||
Setting.ns_min_count = '2'
|
||||
expect(Setting.ns_min_count).to eq('2')
|
||||
Setting.ns_min_count = true
|
||||
expect(Setting.ns_min_count).to eq(true)
|
||||
end
|
||||
end
|
||||
|
|
20
spec/support/general.rb
Normal file
20
spec/support/general.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module General
|
||||
def create_settings
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.include General
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue