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
1ae28e0e
Commit
1ae28e0e
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
Return fake if and only if there's no database
Because `connect_to_db?` already detects if the table exists or not
parent
71672dfa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
21 deletions
+10
-21
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+10
-21
No files found.
lib/gitlab/current_settings.rb
View file @
1ae28e0e
...
...
@@ -7,10 +7,6 @@ module Gitlab
Gitlab
::
SafeRequestStore
.
fetch
(
:current_application_settings
)
{
ensure_application_settings!
}
end
def
fake_application_settings
(
attributes
=
{})
Gitlab
::
FakeApplicationSettings
.
new
(
::
ApplicationSetting
.
defaults
.
merge
(
attributes
||
{}))
end
def
clear_in_memory_application_settings!
@in_memory_application_settings
=
nil
end
...
...
@@ -58,29 +54,22 @@ module Gitlab
.
stringify_keys
.
slice
(
*
column_names
)
return
::
ApplicationSetting
.
new
(
final_attributes
)
::
ApplicationSetting
.
new
(
final_attributes
)
elsif
current_settings
.
present?
current_settings
else
::
ApplicationSetting
.
create_from_defaults
||
in_memory_application_settings
end
return
current_settings
if
current_settings
.
present?
with_fallback_to_fake_application_settings
do
::
ApplicationSetting
.
create_from_defaults
||
in_memory_application_settings
end
def
fake_application_settings
(
attributes
=
{})
Gitlab
::
FakeApplicationSettings
.
new
(
::
ApplicationSetting
.
defaults
.
merge
(
attributes
||
{}))
end
def
in_memory_application_settings
with_fallback_to_fake_application_settings
do
@in_memory_application_settings
||=
::
ApplicationSetting
.
build_from_defaults
end
end
def
with_fallback_to_fake_application_settings
(
&
block
)
yield
rescue
# In case the application_settings table is not created yet, or if a new
# ApplicationSetting column is not yet migrated we fallback to a simple OpenStruct
fake_application_settings
end
def
connect_to_db?
# When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
...
...
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