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
d10642a4
Commit
d10642a4
authored
Jun 29, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle case when Redis cache returns an empty setting
parent
c600cf83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
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
+9
-2
No files found.
lib/gitlab/current_settings.rb
View file @
d10642a4
...
@@ -11,7 +11,7 @@ module Gitlab
...
@@ -11,7 +11,7 @@ module Gitlab
def
ensure_application_settings!
def
ensure_application_settings!
if
connect_to_db?
if
connect_to_db?
begin
begin
settings
=
::
ApplicationSetting
.
c
ached
settings
=
::
ApplicationSetting
.
c
urrent
# In case Redis isn't running or the Redis UNIX socket file is not available
# In case Redis isn't running or the Redis UNIX socket file is not available
rescue
::
Redis
::
BaseError
,
::
Errno
::
ENOENT
rescue
::
Redis
::
BaseError
,
::
Errno
::
ENOENT
settings
=
::
ApplicationSetting
.
last
settings
=
::
ApplicationSetting
.
last
...
...
spec/lib/gitlab/current_settings_spec.rb
View file @
d10642a4
...
@@ -4,7 +4,7 @@ describe Gitlab::CurrentSettings do
...
@@ -4,7 +4,7 @@ describe Gitlab::CurrentSettings do
describe
'#current_application_settings'
do
describe
'#current_application_settings'
do
it
'attempts to use cached values first'
do
it
'attempts to use cached values first'
do
allow_any_instance_of
(
Gitlab
::
CurrentSettings
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
CurrentSettings
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
expect
(
ApplicationSetting
).
to
receive
(
:c
ached
).
and_call_original
expect
(
ApplicationSetting
).
to
receive
(
:c
urrent
).
and_return
(
::
ApplicationSetting
.
create_from_defaults
)
expect
(
ApplicationSetting
).
not_to
receive
(
:last
)
expect
(
ApplicationSetting
).
not_to
receive
(
:last
)
expect
(
current_application_settings
).
to
be_a
(
ApplicationSetting
)
expect
(
current_application_settings
).
to
be_a
(
ApplicationSetting
)
...
@@ -18,9 +18,16 @@ describe Gitlab::CurrentSettings do
...
@@ -18,9 +18,16 @@ describe Gitlab::CurrentSettings do
expect
(
current_application_settings
).
to
eq
fake_application_settings
expect
(
current_application_settings
).
to
eq
fake_application_settings
end
end
it
'falls back to DB if Redis returns an empty value'
do
allow_any_instance_of
(
Gitlab
::
CurrentSettings
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
expect
(
ApplicationSetting
).
to
receive
(
:last
).
and_call_original
expect
(
current_application_settings
).
to
be_a
(
ApplicationSetting
)
end
it
'falls back to DB if Redis fails'
do
it
'falls back to DB if Redis fails'
do
allow_any_instance_of
(
Gitlab
::
CurrentSettings
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
CurrentSettings
).
to
receive
(
:connect_to_db?
).
and_return
(
true
)
expect
(
ApplicationSetting
).
to
receive
(
:c
ached
).
and_raise
(
::
Redis
::
BaseError
)
expect
(
ApplicationSetting
).
to
receive
(
:c
urrent
).
and_raise
(
::
Redis
::
BaseError
)
expect
(
ApplicationSetting
).
to
receive
(
:last
).
and_call_original
expect
(
ApplicationSetting
).
to
receive
(
:last
).
and_call_original
expect
(
current_application_settings
).
to
be_a
(
ApplicationSetting
)
expect
(
current_application_settings
).
to
be_a
(
ApplicationSetting
)
...
...
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