mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Refactor settings
This commit is contained in:
parent
26f5eda636
commit
dafcb6f78c
25 changed files with 132 additions and 282 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue