BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d464d790
Commit
d464d790
authored
Apr 24, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lazily sets UUID in ApplicationSetting for new installations
parent
e2be17b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
application_setting.rb
app/models/application_setting.rb
+9
-0
application_setting_spec.rb
spec/models/application_setting_spec.rb
+1
-0
No files found.
app/models/application_setting.rb
View file @
d464d790
...
@@ -28,6 +28,8 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -28,6 +28,8 @@ class ApplicationSetting < ActiveRecord::Base
attr_accessor
:domain_whitelist_raw
,
:domain_blacklist_raw
attr_accessor
:domain_whitelist_raw
,
:domain_blacklist_raw
validates
:uuid
,
presence:
true
validates
:session_expire_delay
,
validates
:session_expire_delay
,
presence:
true
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
...
@@ -159,6 +161,7 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -159,6 +161,7 @@ class ApplicationSetting < ActiveRecord::Base
end
end
end
end
before_validation
:ensure_uuid!
before_save
:ensure_runners_registration_token
before_save
:ensure_runners_registration_token
before_save
:ensure_health_check_access_token
before_save
:ensure_health_check_access_token
...
@@ -344,6 +347,12 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -344,6 +347,12 @@ class ApplicationSetting < ActiveRecord::Base
private
private
def
ensure_uuid!
return
if
uuid?
self
.
uuid
=
SecureRandom
.
uuid
end
def
check_repository_storages
def
check_repository_storages
invalid
=
repository_storages
-
Gitlab
.
config
.
repositories
.
storages
.
keys
invalid
=
repository_storages
-
Gitlab
.
config
.
repositories
.
storages
.
keys
errors
.
add
(
:repository_storages
,
"can't include:
#{
invalid
.
join
(
", "
)
}
"
)
unless
errors
.
add
(
:repository_storages
,
"can't include:
#{
invalid
.
join
(
", "
)
}
"
)
unless
...
...
spec/models/application_setting_spec.rb
View file @
d464d790
...
@@ -4,6 +4,7 @@ describe ApplicationSetting, models: true do
...
@@ -4,6 +4,7 @@ describe ApplicationSetting, models: true do
let
(
:setting
)
{
ApplicationSetting
.
create_from_defaults
}
let
(
:setting
)
{
ApplicationSetting
.
create_from_defaults
}
it
{
expect
(
setting
).
to
be_valid
}
it
{
expect
(
setting
).
to
be_valid
}
it
{
expect
(
setting
.
uuid
).
to
be_present
}
describe
'validations'
do
describe
'validations'
do
let
(
:http
)
{
'http://example.com'
}
let
(
:http
)
{
'http://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