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
cad8bb18
Commit
cad8bb18
authored
Jun 25, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse the cached value when the it is false
parent
87b468c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
lib/gitlab/json_cache.rb
lib/gitlab/json_cache.rb
+1
-1
spec/lib/gitlab/json_cache_spec.rb
spec/lib/gitlab/json_cache_spec.rb
+34
-1
No files found.
lib/gitlab/json_cache.rb
View file @
cad8bb18
...
...
@@ -34,7 +34,7 @@ module Gitlab
def
read
(
key
,
klass
=
nil
)
value
=
backend
.
read
(
cache_key
(
key
))
value
=
parse_value
(
value
,
klass
)
if
value
value
=
parse_value
(
value
,
klass
)
unless
value
.
nil?
value
end
...
...
spec/lib/gitlab/json_cache_spec.rb
View file @
cad8bb18
...
...
@@ -129,19 +129,52 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
and_return
(
nil
)
expect
(
ActiveSupport
::
JSON
).
not_to
receive
(
:decode
)
expect
(
cache
.
read
(
key
)).
to
be_nil
end
context
'when the cached value is
a boolean
'
do
context
'when the cached value is
true
'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
true
)
expect
(
ActiveSupport
::
JSON
).
to
receive
(
:decode
).
with
(
"true"
).
and_call_original
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
(
true
)
end
end
context
'when the cached value is false'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
false
)
expect
(
ActiveSupport
::
JSON
).
to
receive
(
:decode
).
with
(
"false"
).
and_call_original
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
(
false
)
end
end
context
'when the cached value is a JSON true value'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
"true"
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
(
true
)
end
end
context
'when the cached value is a JSON false value'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
"false"
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
(
false
)
end
end
context
'when the cached value is a hash'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
...
...
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