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
Hide 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
...
@@ -7,7 +7,7 @@ describe Gitlab::JsonCache do
let
(
:namespace
)
{
'geo'
}
let
(
:namespace
)
{
'geo'
}
let
(
:key
)
{
'foo'
}
let
(
:key
)
{
'foo'
}
let
(
:expanded_key
)
{
"
#{
namespace
}
:
#{
key
}
:
#{
Rails
.
version
}
"
}
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
)
}
subject
(
:cache
)
{
described_class
.
new
(
namespace:
namespace
,
backend:
backend
)
}
...
@@ -110,15 +110,15 @@ describe Gitlab::JsonCache do
...
@@ -110,15 +110,15 @@ describe Gitlab::JsonCache do
it
'parses the cached value'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
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
end
it
'returns nil when klass is nil'
do
it
'returns nil when klass is nil'
do
allow
(
backend
).
to
receive
(
:read
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
nod
e
.
to_json
)
.
and_return
(
broadcast_messag
e
.
to_json
)
expect
(
cache
.
read
(
key
)).
to
be_nil
expect
(
cache
.
read
(
key
)).
to
be_nil
end
end
...
@@ -128,7 +128,7 @@ describe Gitlab::JsonCache do
...
@@ -128,7 +128,7 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
'{'
)
.
and_return
(
'{'
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
be_nil
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
be_nil
end
end
it
'gracefully handles an empty hash'
do
it
'gracefully handles an empty hash'
do
...
@@ -136,15 +136,15 @@ describe Gitlab::JsonCache do
...
@@ -136,15 +136,15 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
'{}'
)
.
and_return
(
'{}'
)
expect
(
cache
.
read
(
key
,
GeoNode
)).
to
be_a
(
GeoNod
e
)
expect
(
cache
.
read
(
key
,
BroadcastMessage
)).
to
be_a
(
BroadcastMessag
e
)
end
end
it
'gracefully handles unknown attributes'
do
it
'gracefully handles unknown attributes'
do
allow
(
backend
).
to
receive
(
:read
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
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
end
end
...
@@ -152,15 +152,15 @@ describe Gitlab::JsonCache do
...
@@ -152,15 +152,15 @@ describe Gitlab::JsonCache do
it
'parses the cached value'
do
it
'parses the cached value'
do
allow
(
backend
).
to
receive
(
:read
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
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
end
it
'returns an empty array when klass is nil'
do
it
'returns an empty array when klass is nil'
do
allow
(
backend
).
to
receive
(
:read
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
([
nod
e
].
to_json
)
.
and_return
([
broadcast_messag
e
].
to_json
)
expect
(
cache
.
read
(
key
)).
to
eq
([])
expect
(
cache
.
read
(
key
)).
to
eq
([])
end
end
...
@@ -170,7 +170,7 @@ describe Gitlab::JsonCache do
...
@@ -170,7 +170,7 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
'['
)
.
and_return
(
'['
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
be_nil
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
be_nil
end
end
it
'gracefully handles an empty array'
do
it
'gracefully handles an empty array'
do
...
@@ -178,15 +178,15 @@ describe Gitlab::JsonCache do
...
@@ -178,15 +178,15 @@ describe Gitlab::JsonCache do
.
with
(
expanded_key
)
.
with
(
expanded_key
)
.
and_return
(
'[]'
)
.
and_return
(
'[]'
)
expect
(
cache
.
read
(
key
,
GeoNod
e
)).
to
eq
([])
expect
(
cache
.
read
(
key
,
BroadcastMessag
e
)).
to
eq
([])
end
end
it
'gracefully handles unknown attributes'
do
it
'gracefully handles unknown attributes'
do
allow
(
backend
).
to
receive
(
:read
)
allow
(
backend
).
to
receive
(
:read
)
.
with
(
expanded_key
)
.
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
end
end
end
...
@@ -199,10 +199,10 @@ describe Gitlab::JsonCache do
...
@@ -199,10 +199,10 @@ describe Gitlab::JsonCache do
end
end
it
'writes a string containing a JSON representation of the value to the cache'
do
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
)
expect
(
backend
).
to
have_received
(
:write
)
.
with
(
expanded_key
,
nod
e
.
to_json
,
nil
)
.
with
(
expanded_key
,
broadcast_messag
e
.
to_json
,
nil
)
end
end
it
'passes options the underlying cache implementation'
do
it
'passes options the underlying cache implementation'
do
...
@@ -288,13 +288,13 @@ describe Gitlab::JsonCache do
...
@@ -288,13 +288,13 @@ describe Gitlab::JsonCache do
context
'when the given key exists in the cache'
do
context
'when the given key exists in the cache'
do
context
'when the cached value is a hash'
do
context
'when the cached value is a hash'
do
before
do
before
do
backend
.
write
(
expanded_key
,
nod
e
.
to_json
)
backend
.
write
(
expanded_key
,
broadcast_messag
e
.
to_json
)
end
end
it
'parses the cached value'
do
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
end
it
"returns the result of the block when 'as' option is nil"
do
it
"returns the result of the block when 'as' option is nil"
do
...
@@ -312,13 +312,13 @@ describe Gitlab::JsonCache do
...
@@ -312,13 +312,13 @@ describe Gitlab::JsonCache do
context
'when the cached value is a array'
do
context
'when the cached value is a array'
do
before
do
before
do
backend
.
write
(
expanded_key
,
[
nod
e
].
to_json
)
backend
.
write
(
expanded_key
,
[
broadcast_messag
e
].
to_json
)
end
end
it
'parses the cached value'
do
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
end
it
"returns an empty array when 'as' option is nil"
do
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