Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
c909b6aa
Commit
c909b6aa
authored
Oct 05, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent creating multiple ApplicationSetting by forcing it to always have id=1
parent
2087f121
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
0 deletions
+17
-0
app/models/application_setting.rb
app/models/application_setting.rb
+2
-0
changelogs/unreleased/prevent-creating-multiple-application-settings.yml
...leased/prevent-creating-multiple-application-settings.yml
+5
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+10
-0
No files found.
app/models/application_setting.rb
View file @
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
,
...
...
changelogs/unreleased/prevent-creating-multiple-application-settings.yml
0 → 100644
View file @
c909b6aa
---
title
:
Prevent creating multiple ApplicationSetting instances
merge_request
:
author
:
type
:
fixed
spec/models/application_setting_spec.rb
View file @
c909b6aa
...
@@ -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'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment