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
5da16a00
Commit
5da16a00
authored
Dec 19, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Gitlab::JsonCache outside ee/ folder
parent
891652c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
23 deletions
+23
-23
lib/gitlab/json_cache.rb
lib/gitlab/json_cache.rb
+0
-0
spec/lib/gitlab/json_cache_spec.rb
spec/lib/gitlab/json_cache_spec.rb
+23
-23
No files found.
ee/
lib/gitlab/json_cache.rb
→
lib/gitlab/json_cache.rb
View file @
5da16a00
File moved
ee/
spec/lib/gitlab/json_cache_spec.rb
→
spec/lib/gitlab/json_cache_spec.rb
View file @
5da16a00
...
...
@@ -7,7 +7,7 @@ describe Gitlab::JsonCache do
let
(
:namespace
)
{
'geo'
}
let
(
:key
)
{
'foo'
}
let
(
:expanded_key
)
{
"
#{
namespace
}
:
#{
key
}
:
#{
Rails
.
version
}
"
}
let
(
:
node
)
{
create
(
:geo_nod
e
)
}
let
(
:
broadcast_message
)
{
create
(
:broadcast_messag
e
)
}
subject
(
:cache
)
{
described_class
.
new
(
namespace:
namespace
,
backend:
backend
)
}
...
...
@@ -110,15 +110,15 @@ describe Gitlab::JsonCache do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
nod
e
.
to_json
)
.
and_return
(
broadcast_messag
e
.
to_json
)
expect
(
cache
.
read
(
key
,
GeoNode
)).
to
eq
(
nod
e
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
(
broadcast_messag
e
)
end
it
'returns nil when klass is nil'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
nod
e
.
to_json
)
.
and_return
(
broadcast_messag
e
.
to_json
)
expect
(
cache
.
read
(
key
)).
to
be_nil
end
...
...
@@ -128,7 +128,7 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
and_return
(
'{'
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
be_nil
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
be_nil
end
it
'gracefully handles an empty hash'
do
...
...
@@ -136,15 +136,15 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
and_return
(
'{}'
)
expect
(
cache
.
read
(
key
,
GeoNode
)).
to
be_a
(
GeoNod
e
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_a
(
BroadcastMessag
e
)
end
it
'gracefully handles unknown attributes'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
(
nod
e
.
attributes
.
merge
(
unknown_attribute:
1
).
to_json
)
.
and_return
(
broadcast_messag
e
.
attributes
.
merge
(
unknown_attribute:
1
).
to_json
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
be_nil
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
be_nil
end
end
...
...
@@ -152,15 +152,15 @@ describe Gitlab::JsonCache do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
([
nod
e
].
to_json
)
.
and_return
([
broadcast_messag
e
].
to_json
)
expect
(
cache
.
read
(
key
,
GeoNode
)).
to
eq
([
nod
e
])
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
([
broadcast_messag
e
])
end
it
'returns an empty array when klass is nil'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
([
nod
e
].
to_json
)
.
and_return
([
broadcast_messag
e
].
to_json
)
expect
(
cache
.
read
(
key
)).
to
eq
([])
end
...
...
@@ -170,7 +170,7 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
and_return
(
'['
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
be_nil
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
be_nil
end
it
'gracefully handles an empty array'
do
...
...
@@ -178,15 +178,15 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
and_return
(
'[]'
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
eq
([])
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
eq
([])
end
it
'gracefully handles unknown attributes'
do
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
and_return
([{
unknown_attribute:
1
},
nod
e
.
attributes
].
to_json
)
.
and_return
([{
unknown_attribute:
1
},
broadcast_messag
e
.
attributes
].
to_json
)
expect
(
cache
.
read
(
key
,
GeoNode
)).
to
eq
([
nod
e
])
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
eq
([
broadcast_messag
e
])
end
end
end
...
...
@@ -199,10 +199,10 @@ describe Gitlab::JsonCache do
end
it
'writes a string containing a JSON representation of the value to the cache'
do
cache
.
write
(
key
,
nod
e
)
cache
.
write
(
key
,
broadcast_messag
e
)
expect
(
backend
).
to
have_received
(
:write
)
.
with
(
expanded_key
,
nod
e
.
to_json
,
nil
)
.
with
(
expanded_key
,
broadcast_messag
e
.
to_json
,
nil
)
end
it
'passes options the underlying cache implementation'
do
...
...
@@ -288,13 +288,13 @@ describe Gitlab::JsonCache do
context
'when the given key exists in the cache'
do
context
'when the cached value is a hash'
do
before
do
backend
.
write
(
expanded_key
,
nod
e
.
to_json
)
backend
.
write
(
expanded_key
,
broadcast_messag
e
.
to_json
)
end
it
'parses the cached value'
do
result
=
cache
.
fetch
(
key
,
as:
GeoNod
e
)
{
'block result'
}
result
=
cache
.
fetch
(
key
,
as:
BroadcastMessag
e
)
{
'block result'
}
expect
(
result
).
to
eq
(
nod
e
)
expect
(
result
).
to
eq
(
broadcast_messag
e
)
end
it
"returns the result of the block when 'as' option is nil"
do
...
...
@@ -312,13 +312,13 @@ describe Gitlab::JsonCache do
context
'when the cached value is a array'
do
before
do
backend
.
write
(
expanded_key
,
[
nod
e
].
to_json
)
backend
.
write
(
expanded_key
,
[
broadcast_messag
e
].
to_json
)
end
it
'parses the cached value'
do
result
=
cache
.
fetch
(
key
,
as:
GeoNod
e
)
{
'block result'
}
result
=
cache
.
fetch
(
key
,
as:
BroadcastMessag
e
)
{
'block result'
}
expect
(
result
).
to
eq
([
nod
e
])
expect
(
result
).
to
eq
([
broadcast_messag
e
])
end
it
"returns an empty array when 'as' option is nil"
do
...
...
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