Skip to content
Snippets Groups Projects
Commit c909b6aa authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Prevent creating multiple ApplicationSetting by forcing it to always have id=1

parent 2087f121
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -33,6 +33,8 @@ class ApplicationSetting < ActiveRecord::Base
 
attr_accessor :domain_whitelist_raw, :domain_blacklist_raw
 
default_value_for :id, 1
validates :uuid, presence: true
 
validates :session_expire_delay,
Loading
Loading
---
title: Prevent creating multiple ApplicationSetting instances
merge_request:
author:
type: fixed
Loading
Loading
@@ -209,6 +209,16 @@ describe ApplicationSetting do
end
end
 
context 'restrict creating duplicates' do
before do
described_class.create_from_defaults
end
it 'raises an record creation violation if already created' do
expect { described_class.create_from_defaults }.to raise_error(ActiveRecord::RecordNotUnique)
end
end
context 'restricted signup domains' do
it 'sets single domain' do
setting.domain_whitelist_raw = 'example.com'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment