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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f37f28b9
Commit
f37f28b9
authored
Mar 18, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix race cond. in ApplicationSettingImplementation.create_from_defaults
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
a6e9175f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
20 deletions
+23
-20
app/models/application_setting.rb
app/models/application_setting.rb
+7
-0
db/fixtures/development/02_application_settings.rb
db/fixtures/development/02_application_settings.rb
+10
-0
db/fixtures/development/02_settings.rb
db/fixtures/development/02_settings.rb
+0
-8
db/fixtures/development/08_settings.rb
db/fixtures/development/08_settings.rb
+0
-7
db/fixtures/production/001_application_settings.rb
db/fixtures/production/001_application_settings.rb
+2
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+4
-5
No files found.
app/models/application_setting.rb
View file @
f37f28b9
...
...
@@ -223,4 +223,11 @@ class ApplicationSetting < ApplicationRecord
reset_memoized_terms
end
after_commit
:expire_performance_bar_allowed_user_ids_cache
,
if:
->
{
previous_changes
.
key?
(
'performance_bar_allowed_group_id'
)
}
def
self
.
create_from_defaults
super
rescue
ActiveRecord
::
RecordNotUnique
# We already have an ApplicationSetting record, so just return it.
current_without_cache
end
end
db/fixtures/development/02_application_settings.rb
0 → 100644
View file @
f37f28b9
# frozen_string_literal: true
puts
"Creating the default ApplicationSetting record."
.
color
(
:green
)
Gitlab
::
CurrentSettings
.
current_application_settings
# Details https://gitlab.com/gitlab-org/gitlab-ce/issues/46241
puts
"Enable hashed storage for every new projects."
.
color
(
:green
)
ApplicationSetting
.
current_without_cache
.
update!
(
hashed_storage_enabled:
true
)
print
'.'
db/fixtures/development/02_settings.rb
deleted
100644 → 0
View file @
a6e9175f
# frozen_string_literal: true
# Enable hashed storage, in development mode, for all projects by default.
Gitlab
::
Seeder
.
quiet
do
ApplicationSetting
.
create_from_defaults
unless
ApplicationSetting
.
current_without_cache
ApplicationSetting
.
current_without_cache
.
update!
(
hashed_storage_enabled:
true
)
print
'.'
end
db/fixtures/development/08_settings.rb
deleted
100644 → 0
View file @
a6e9175f
# We want to enable hashed storage for every new project in development
# Details https://gitlab.com/gitlab-org/gitlab-ce/issues/46241
Gitlab
::
Seeder
.
quiet
do
ApplicationSetting
.
create_from_defaults
unless
ApplicationSetting
.
current_without_cache
ApplicationSetting
.
current_without_cache
.
update!
(
hashed_storage_enabled:
true
)
print
'.'
end
db/fixtures/production/001_application_settings.rb
View file @
f37f28b9
# frozen_string_literal: true
puts
"Creating the default ApplicationSetting record."
.
color
(
:green
)
Gitlab
::
CurrentSettings
.
current_application_settings
spec/models/application_setting_spec.rb
View file @
f37f28b9
...
...
@@ -6,6 +6,7 @@ describe ApplicationSetting do
let
(
:setting
)
{
described_class
.
create_from_defaults
}
it
{
include
(
CacheableAttributes
)
}
it
{
include
(
ApplicationSettingImplementation
)
}
it
{
expect
(
described_class
.
current_without_cache
).
to
eq
(
described_class
.
last
)
}
it
{
expect
(
setting
).
to
be_valid
}
...
...
@@ -286,12 +287,10 @@ describe ApplicationSetting do
end
context
'restrict creating duplicates'
do
before
do
described_class
.
create_from_defaults
end
let!
(
:current_settings
)
{
described_class
.
create_from_defaults
}
it
'r
aises an record creation violation if already created
'
do
expect
{
described_class
.
create_from_defaults
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
it
'r
eturns the current settings
'
do
expect
(
described_class
.
create_from_defaults
).
to
eq
(
current_settings
)
end
end
...
...
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