mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Merge pull request #583 from internetee/refactor-settings
Refactor settings
This commit is contained in:
commit
80fa2a376c
16 changed files with 199 additions and 187 deletions
13
spec/features/admin/settings/create_spec.rb
Normal file
13
spec/features/admin/settings/create_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.feature 'Admin settings' do
|
||||
background do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'saves settings' do
|
||||
visit admin_settings_path
|
||||
click_link_or_button 'Save'
|
||||
expect(page).to have_text(t('admin.settings.create.saved'))
|
||||
end
|
||||
end
|
|
@ -1,11 +1,61 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Setting do
|
||||
it 'returns value' do
|
||||
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)
|
||||
RSpec.describe Setting do
|
||||
describe 'integer_settings', db: false do
|
||||
it 'returns integer settings' do
|
||||
settings = %i[
|
||||
admin_contacts_min_count
|
||||
admin_contacts_max_count
|
||||
tech_contacts_min_count
|
||||
tech_contacts_max_count
|
||||
orphans_contacts_in_months
|
||||
ds_digest_type
|
||||
dnskeys_min_count
|
||||
dnskeys_max_count
|
||||
ns_min_count
|
||||
ns_max_count
|
||||
transfer_wait_time
|
||||
invoice_number_min
|
||||
invoice_number_max
|
||||
days_to_keep_business_registry_cache
|
||||
days_to_keep_invoices_active
|
||||
days_to_keep_overdue_invoices_active
|
||||
days_to_renew_domain_before_expire
|
||||
expire_warning_period
|
||||
redemption_grace_period
|
||||
expire_pending_confirmation
|
||||
]
|
||||
|
||||
expect(described_class.integer_settings).to eq(settings)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'float_settings', db: false do
|
||||
it 'returns float settings' do
|
||||
settings = %i[
|
||||
registry_vat_prc
|
||||
minimum_deposit
|
||||
]
|
||||
|
||||
expect(described_class.float_settings).to eq(settings)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'boolean_settings', db: false do
|
||||
it 'returns boolean settings' do
|
||||
settings = %i[
|
||||
ds_data_allowed
|
||||
key_data_allowed
|
||||
client_side_status_editing_enabled
|
||||
registrar_ip_whitelist_enabled
|
||||
api_ip_whitelist_enabled
|
||||
request_confrimation_on_registrant_change_enabled
|
||||
request_confirmation_on_domain_deletion_enabled
|
||||
nameserver_required
|
||||
address_processing
|
||||
]
|
||||
|
||||
expect(described_class.boolean_settings).to eq(settings)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
35
spec/requests/admin/settings/create_spec.rb
Normal file
35
spec/requests/admin/settings/create_spec.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Admin settings saving' do
|
||||
before do
|
||||
sign_in_to_admin_area
|
||||
end
|
||||
|
||||
it 'saves integer setting' do
|
||||
allow(Setting).to receive(:integer_settings) { %i[test_setting] }
|
||||
post admin_settings_path, settings: { test_setting: '1' }
|
||||
expect(Setting.test_setting).to eq(1)
|
||||
end
|
||||
|
||||
it 'saves float setting' do
|
||||
allow(Setting).to receive(:float_settings) { %i[test_setting] }
|
||||
post admin_settings_path, settings: { test_setting: '1.2' }
|
||||
expect(Setting.test_setting).to eq(1.2)
|
||||
end
|
||||
|
||||
it 'saves boolean setting' do
|
||||
allow(Setting).to receive(:boolean_settings) { %i[test_setting] }
|
||||
post admin_settings_path, settings: { test_setting: 'true' }
|
||||
expect(Setting.test_setting).to be true
|
||||
end
|
||||
|
||||
it 'saves string setting' do
|
||||
post admin_settings_path, settings: { test_setting: 'test' }
|
||||
expect(Setting.test_setting).to eq('test')
|
||||
end
|
||||
|
||||
it 'redirects to :index' do
|
||||
post admin_settings_path, settings: { test: 'test' }
|
||||
expect(response).to redirect_to admin_settings_path
|
||||
end
|
||||
end
|
|
@ -11,7 +11,11 @@ module Matchers
|
|||
end
|
||||
|
||||
def failure_message
|
||||
"Expected EPP code of #{expected}, got #{actual} (#{description})"
|
||||
"Expected EPP code of #{expected}, got #{actual} (#{code_description})"
|
||||
end
|
||||
|
||||
def description
|
||||
"should have EPP code of #{expected}"
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -23,7 +27,7 @@ module Matchers
|
|||
xml_document.xpath('//xmlns:result').first['code'].to_i
|
||||
end
|
||||
|
||||
def description
|
||||
def code_description
|
||||
xml_document.css('result msg').text
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.configure do |config|
|
|||
Setting.ds_algorithm = 2
|
||||
Setting.ds_data_allowed = true
|
||||
Setting.ds_data_with_key_allowed = true
|
||||
Setting.key_data_allowed = true
|
||||
Setting.key_data_allowed = false
|
||||
|
||||
Setting.dnskeys_min_count = 0
|
||||
Setting.dnskeys_max_count = 9
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue