BigW Consortium Gitlab

Commit c909b6aa by Kamil Trzcinski

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

parent 2087f121
...@@ -33,6 +33,8 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -33,6 +33,8 @@ class ApplicationSetting < ActiveRecord::Base
attr_accessor :domain_whitelist_raw, :domain_blacklist_raw attr_accessor :domain_whitelist_raw, :domain_blacklist_raw
default_value_for :id, 1
validates :uuid, presence: true validates :uuid, presence: true
validates :session_expire_delay, validates :session_expire_delay,
......
---
title: Prevent creating multiple ApplicationSetting instances
merge_request:
author:
type: fixed
...@@ -209,6 +209,16 @@ describe ApplicationSetting do ...@@ -209,6 +209,16 @@ describe ApplicationSetting do
end end
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 context 'restricted signup domains' do
it 'sets single domain' do it 'sets single domain' do
setting.domain_whitelist_raw = 'example.com' setting.domain_whitelist_raw = 'example.com'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment