Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f69c0f80
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f69c0f80
编写于
7月 18, 2017
作者:
L
Lin Jen-Shin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unneeded asserts and add tests for inactive RequestStore
上级
3922b803
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
28 deletion
+20
-28
spec/lib/gitlab/cache/request_cache_spec.rb
spec/lib/gitlab/cache/request_cache_spec.rb
+20
-28
未找到文件。
spec/lib/gitlab/cache/request_cache_spec.rb
浏览文件 @
f69c0f80
require
'spec_helper'
describe
Gitlab
::
Cache
::
RequestCache
,
:request_store
do
describe
Gitlab
::
Cache
::
RequestCache
do
let
(
:klass
)
do
Class
.
new
do
extend
Gitlab
::
Cache
::
RequestCache
...
...
@@ -35,13 +35,12 @@ describe Gitlab::Cache::RequestCache, :request_store do
let
(
:algorithm
)
{
klass
.
new
(
'id'
,
'name'
,
[])
}
context
'when RequestStore is activ
e'
do
shared_examples
'cache for the same instanc
e'
do
it
'does not compute twice for the same argument'
do
algorithm
.
compute
(
true
)
result
=
algorithm
.
compute
(
true
)
expect
(
result
).
to
eq
([
true
])
expect
(
algorithm
.
compute
(
true
)).
to
eq
(
result
)
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
it
'computes twice for the different argument'
do
...
...
@@ -49,7 +48,6 @@ describe Gitlab::Cache::RequestCache, :request_store do
result
=
algorithm
.
compute
(
false
)
expect
(
result
).
to
eq
([
true
,
false
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
it
'computes twice for the different class name'
do
...
...
@@ -58,7 +56,6 @@ describe Gitlab::Cache::RequestCache, :request_store do
result
=
algorithm
.
compute
(
true
)
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
it
'computes twice for the different method'
do
...
...
@@ -66,18 +63,6 @@ describe Gitlab::Cache::RequestCache, :request_store do
result
=
algorithm
.
repute
(
true
)
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
it
'computes twice if RequestStore starts over'
do
algorithm
.
compute
(
true
)
RequestStore
.
end!
RequestStore
.
clear!
RequestStore
.
begin!
result
=
algorithm
.
compute
(
true
)
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
context
'when request_cache_key is provided'
do
...
...
@@ -93,7 +78,6 @@ describe Gitlab::Cache::RequestCache, :request_store do
result
=
algorithm
.
compute
(
true
)
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
it
'computes twice for the different keys, name'
do
...
...
@@ -102,7 +86,6 @@ describe Gitlab::Cache::RequestCache, :request_store do
result
=
algorithm
.
compute
(
true
)
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
it
'uses extra method cache key if provided'
do
...
...
@@ -112,30 +95,39 @@ describe Gitlab::Cache::RequestCache, :request_store do
result
=
algorithm
.
dispute
(
true
)
# hit
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
end
end
context
'when RequestStore is inactive'
do
before
do
RequestStore
.
end!
context
'when RequestStore is active'
,
:request_store
do
it_behaves_like
'cache for the same instance'
it
'computes once for different instances when keys are the same'
do
algorithm
.
compute
(
true
)
result
=
klass
.
new
(
'id'
,
'name'
,
algorithm
.
result
).
compute
(
true
)
expect
(
result
).
to
eq
([
true
])
end
it
'computes
only once if it is the same instance for the same key
'
do
it
'computes
twice if RequestStore starts over
'
do
algorithm
.
compute
(
true
)
RequestStore
.
end!
RequestStore
.
clear!
RequestStore
.
begin!
result
=
algorithm
.
compute
(
true
)
expect
(
result
).
to
eq
([
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
expect
(
result
).
to
eq
([
true
,
true
])
end
end
context
'when RequestStore is inactive'
do
it_behaves_like
'cache for the same instance'
it
'computes twice for different instances even if keys are the same'
do
algorithm
.
compute
(
true
)
result
=
klass
.
new
(
'id'
,
'name'
,
algorithm
.
result
).
compute
(
true
)
expect
(
result
).
to
eq
([
true
,
true
])
expect
(
algorithm
.
result
).
to
eq
(
result
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录