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
3a032a1f
Commit
3a032a1f
authored
Jun 26, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
2c2daf3b
3221f1a7
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 @
3a032a1f
...
...
@@ -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 @
3a032a1f
...
...
@@ -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