Commit 65a1cbc6 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'prevent-creating-multiple-application-settings' into 'master'

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

Closes #34728

See merge request gitlab-org/gitlab-ce!14718
parents 526c4761 c909b6aa
...@@ -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
...@@ -222,6 +222,16 @@ describe ApplicationSetting do ...@@ -222,6 +222,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