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
cc5099c5
Commit
cc5099c5
authored
Dec 14, 2018
by
Lin Jen-Shin
Committed by
Rémy Coutable
Dec 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move schema aware defaults to build_from_defaults
This way we can reuse the safe setting
parent
1ae28e0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
app/models/concerns/cacheable_attributes.rb
app/models/concerns/cacheable_attributes.rb
+6
-1
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+1
-8
No files found.
app/models/concerns/cacheable_attributes.rb
View file @
cc5099c5
...
...
@@ -23,7 +23,12 @@ module CacheableAttributes
end
def
build_from_defaults
(
attributes
=
{})
new
(
defaults
.
merge
(
attributes
))
final_attributes
=
defaults
.
merge
(
attributes
)
.
stringify_keys
.
slice
(
*
column_names
)
new
(
final_attributes
)
end
def
cached
...
...
lib/gitlab/current_settings.rb
View file @
cc5099c5
...
...
@@ -47,14 +47,7 @@ module Gitlab
# defaults for missing columns.
if
ActiveRecord
::
Migrator
.
needs_migration?
db_attributes
=
current_settings
&
.
attributes
||
{}
column_names
=
::
ApplicationSetting
.
column_names
final_attributes
=
::
ApplicationSetting
.
defaults
.
merge
(
db_attributes
)
.
stringify_keys
.
slice
(
*
column_names
)
::
ApplicationSetting
.
new
(
final_attributes
)
::
ApplicationSetting
.
build_from_defaults
(
db_attributes
)
elsif
current_settings
.
present?
current_settings
else
...
...
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