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
b7de942a
Commit
b7de942a
authored
Apr 15, 2020
by
Dmitry Gruzd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not ignore database connection errors
parent
b87db076
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
22 deletions
+10
-22
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+1
-1
spec/lib/gitlab/current_settings_spec.rb
spec/lib/gitlab/current_settings_spec.rb
+6
-21
spec/support/helpers/migrations_helpers.rb
spec/support/helpers/migrations_helpers.rb
+3
-0
No files found.
lib/gitlab/current_settings.rb
View file @
b7de942a
...
...
@@ -43,7 +43,7 @@ module Gitlab
end
def
uncached_application_settings
return
fake_application_settings
unless
connect_to_db?
return
fake_application_settings
if
Gitlab
::
Runtime
.
rake?
&&
!
connect_to_db?
current_settings
=
::
ApplicationSetting
.
current
# If there are pending migrations, it's possible there are columns that
...
...
spec/lib/gitlab/current_settings_spec.rb
View file @
b7de942a
...
...
@@ -49,20 +49,16 @@ describe Gitlab::CurrentSettings do
end
end
context
'with DB unavailable'
do
context
'and settings in cache'
do
include_context
'with settings in cache'
it
'fetches the settings from cache without issuing any query'
do
expect
(
ActiveRecord
::
QueryRecorder
.
new
{
described_class
.
current_application_settings
}.
count
).
to
eq
(
0
)
end
context
'in a Rake task with DB unavailable'
do
before
do
allow
(
Gitlab
::
Runtime
).
to
receive
(
:rake?
).
and_return
(
true
)
# For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(false)` causes issues
# during the initialization phase of the test suite, so instead let's mock the internals of it
allow
(
ActiveRecord
::
Base
.
connection
).
to
receive
(
:active?
).
and_return
(
false
)
end
context
'and no settings in cache'
do
before
do
# For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(false)` causes issues
# during the initialization phase of the test suite, so instead let's mock the internals of it
allow
(
ActiveRecord
::
Base
.
connection
).
to
receive
(
:active?
).
and_return
(
false
)
expect
(
ApplicationSetting
).
not_to
receive
(
:current
)
end
...
...
@@ -185,17 +181,6 @@ describe Gitlab::CurrentSettings do
expect
(
described_class
.
current_application_settings
).
to
eq
(
:current_settings
)
end
end
context
'when the application_settings table does not exist'
do
it
'returns a FakeApplicationSettings object'
do
expect
(
Gitlab
::
Database
)
.
to
receive
(
:cached_table_exists?
)
.
with
(
'application_settings'
)
.
and_return
(
false
)
expect
(
described_class
.
current_application_settings
).
to
be_a
(
Gitlab
::
FakeApplicationSettings
)
end
end
end
end
end
...
...
spec/support/helpers/migrations_helpers.rb
View file @
b7de942a
...
...
@@ -80,6 +80,9 @@ module MigrationsHelpers
allow
(
ActiveRecord
::
Base
.
connection
)
.
to
receive
(
:active?
)
.
and_return
(
false
)
allow
(
Gitlab
::
Runtime
)
.
to
receive
(
:rake?
)
.
and_return
(
true
)
stub_env
(
'IN_MEMORY_APPLICATION_SETTINGS'
,
'false'
)
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