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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
2123b789
Commit
2123b789
authored
Nov 16, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change specs to accept new cache keys for projects
parent
cb541aef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
spec/lib/gitlab/repository_cache_spec.rb
spec/lib/gitlab/repository_cache_spec.rb
+11
-11
No files found.
spec/lib/gitlab/repository_cache_spec.rb
View file @
2123b789
...
@@ -4,14 +4,14 @@ describe Gitlab::RepositoryCache do
...
@@ -4,14 +4,14 @@ describe Gitlab::RepositoryCache do
let
(
:backend
)
{
double
(
'backend'
).
as_null_object
}
let
(
:backend
)
{
double
(
'backend'
).
as_null_object
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:repository
)
{
project
.
repository
}
let
(
:namespace
)
{
"
#{
repository
.
full_path
}
:
#{
project
.
id
}
"
}
let
(
:namespace
)
{
"
project
:
#{
project
.
id
}
"
}
let
(
:cache
)
{
described_class
.
new
(
repository
,
backend:
backend
)
}
let
(
:cache
)
{
described_class
.
new
(
repository
,
backend:
backend
)
}
describe
'#cache_key'
do
describe
'#cache_key'
do
subject
{
cache
.
cache_key
(
:foo
)
}
subject
{
cache
.
cache_key
(
:foo
)
}
it
'includes the namespace'
do
it
'includes the namespace'
do
expect
(
subject
).
to
eq
"
foo:
#{
namespace
}
"
expect
(
subject
).
to
eq
"
#{
namespace
}
:foo
"
end
end
context
'with a given namespace'
do
context
'with a given namespace'
do
...
@@ -22,7 +22,7 @@ describe Gitlab::RepositoryCache do
...
@@ -22,7 +22,7 @@ describe Gitlab::RepositoryCache do
end
end
it
'includes the full namespace'
do
it
'includes the full namespace'
do
expect
(
subject
).
to
eq
"
foo:
#{
namespace
}
:
#{
extra_namespace
}
"
expect
(
subject
).
to
eq
"
#{
namespace
}
:
#{
extra_namespace
}
:foo
"
end
end
end
end
end
end
...
@@ -30,21 +30,21 @@ describe Gitlab::RepositoryCache do
...
@@ -30,21 +30,21 @@ describe Gitlab::RepositoryCache do
describe
'#expire'
do
describe
'#expire'
do
it
'expires the given key from the cache'
do
it
'expires the given key from the cache'
do
cache
.
expire
(
:foo
)
cache
.
expire
(
:foo
)
expect
(
backend
).
to
have_received
(
:delete
).
with
(
"
foo:
#{
namespace
}
"
)
expect
(
backend
).
to
have_received
(
:delete
).
with
(
"
#{
namespace
}
:foo
"
)
end
end
end
end
describe
'#fetch'
do
describe
'#fetch'
do
it
'fetches the given key from the cache'
do
it
'fetches the given key from the cache'
do
cache
.
fetch
(
:bar
)
cache
.
fetch
(
:bar
)
expect
(
backend
).
to
have_received
(
:fetch
).
with
(
"
bar:
#{
namespace
}
"
)
expect
(
backend
).
to
have_received
(
:fetch
).
with
(
"
#{
namespace
}
:bar
"
)
end
end
it
'accepts a block'
do
it
'accepts a block'
do
p
=
->
{}
p
=
->
{}
cache
.
fetch
(
:baz
,
&
p
)
cache
.
fetch
(
:baz
,
&
p
)
expect
(
backend
).
to
have_received
(
:fetch
).
with
(
"
baz:
#{
namespace
}
"
,
&
p
)
expect
(
backend
).
to
have_received
(
:fetch
).
with
(
"
#{
namespace
}
:baz
"
,
&
p
)
end
end
end
end
...
@@ -67,7 +67,7 @@ describe Gitlab::RepositoryCache do
...
@@ -67,7 +67,7 @@ describe Gitlab::RepositoryCache do
end
end
it
'caches the value'
do
it
'caches the value'
do
expect
(
backend
).
to
receive
(
:write
).
with
(
"
#{
key
}
:
#{
namespace
}
"
,
true
)
expect
(
backend
).
to
receive
(
:write
).
with
(
"
#{
namespace
}
:
#{
key
}
"
,
true
)
cache
.
fetch_without_caching_false
(
key
)
{
true
}
cache
.
fetch_without_caching_false
(
key
)
{
true
}
end
end
...
@@ -83,7 +83,7 @@ describe Gitlab::RepositoryCache do
...
@@ -83,7 +83,7 @@ describe Gitlab::RepositoryCache do
end
end
it
'does not cache the value'
do
it
'does not cache the value'
do
expect
(
backend
).
not_to
receive
(
:write
).
with
(
"
#{
key
}
:
#{
namespace
}
"
,
true
)
expect
(
backend
).
not_to
receive
(
:write
).
with
(
"
#{
namespace
}
:
#{
key
}
"
,
true
)
cache
.
fetch_without_caching_false
(
key
,
&
p
)
cache
.
fetch_without_caching_false
(
key
,
&
p
)
end
end
...
@@ -92,7 +92,7 @@ describe Gitlab::RepositoryCache do
...
@@ -92,7 +92,7 @@ describe Gitlab::RepositoryCache do
context
'when the cached value is truthy'
do
context
'when the cached value is truthy'
do
before
do
before
do
backend
.
write
(
"
#{
key
}
:
#{
namespace
}
"
,
true
)
backend
.
write
(
"
#{
namespace
}
:
#{
key
}
"
,
true
)
end
end
it
'returns the cached value'
do
it
'returns the cached value'
do
...
@@ -116,7 +116,7 @@ describe Gitlab::RepositoryCache do
...
@@ -116,7 +116,7 @@ describe Gitlab::RepositoryCache do
context
'when the cached value is falsey'
do
context
'when the cached value is falsey'
do
before
do
before
do
backend
.
write
(
"
#{
key
}
:
#{
namespace
}
"
,
false
)
backend
.
write
(
"
#{
namespace
}
:
#{
key
}
"
,
false
)
end
end
it
'returns the result of the block'
do
it
'returns the result of the block'
do
...
@@ -126,7 +126,7 @@ describe Gitlab::RepositoryCache do
...
@@ -126,7 +126,7 @@ describe Gitlab::RepositoryCache do
end
end
it
'writes the truthy value to the cache'
do
it
'writes the truthy value to the cache'
do
expect
(
backend
).
to
receive
(
:write
).
with
(
"
#{
key
}
:
#{
namespace
}
"
,
'block result'
)
expect
(
backend
).
to
receive
(
:write
).
with
(
"
#{
namespace
}
:
#{
key
}
"
,
'block result'
)
cache
.
fetch_without_caching_false
(
key
)
{
'block result'
}
cache
.
fetch_without_caching_false
(
key
)
{
'block result'
}
end
end
...
...
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