Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
56739bcaf190
Commit
d464d790
authored
Apr 24, 2017
by
Douglas Barbosa Alexandre
Browse files
Lazily sets UUID in ApplicationSetting for new installations
parent
4b58d05ada5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/application_setting.rb
View file @
56739bca
...
...
@@ -28,6 +28,8 @@ class ApplicationSetting < ActiveRecord::Base
attr_accessor
:domain_whitelist_raw
,
:domain_blacklist_raw
validates
:uuid
,
presence:
true
validates
:session_expire_delay
,
presence:
true
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
}
...
...
@@ -159,6 +161,7 @@ class ApplicationSetting < ActiveRecord::Base
end
end
before_validation
:ensure_uuid!
before_save
:ensure_runners_registration_token
before_save
:ensure_health_check_access_token
...
...
@@ -344,6 +347,12 @@ def sidekiq_throttling_enabled?
private
def
ensure_uuid!
return
if
uuid?
self
.
uuid
=
SecureRandom
.
uuid
end
def
check_repository_storages
invalid
=
repository_storages
-
Gitlab
.
config
.
repositories
.
storages
.
keys
errors
.
add
(
:repository_storages
,
"can't include:
#{
invalid
.
join
(
", "
)
}
"
)
unless
...
...
spec/models/application_setting_spec.rb
View file @
56739bca
...
...
@@ -4,6 +4,7 @@
let
(
:setting
)
{
ApplicationSetting
.
create_from_defaults
}
it
{
expect
(
setting
).
to
be_valid
}
it
{
expect
(
setting
.
uuid
).
to
be_present
}
describe
'validations'
do
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