Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
ce869e39
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,体验更适合开发者的 AI 搜索 >>
提交
ce869e39
编写于
5月 30, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Diff#too_large? and specs
上级
d9461314
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
53 deletion
+25
-53
lib/gitlab/git/diff.rb
lib/gitlab/git/diff.rb
+5
-3
spec/helpers/blob_helper_spec.rb
spec/helpers/blob_helper_spec.rb
+9
-11
spec/lib/gitlab/git/diff_spec.rb
spec/lib/gitlab/git/diff_spec.rb
+7
-7
spec/models/blob_viewer/base_spec.rb
spec/models/blob_viewer/base_spec.rb
+4
-32
未找到文件。
lib/gitlab/git/diff.rb
浏览文件 @
ce869e39
...
...
@@ -230,9 +230,11 @@ module Gitlab
end
def
too_large?
return
@too_large
if
defined?
(
@too_large
)
@too_large
=
@diff
.
bytesize
>=
SIZE_LIMIT
if
@too_large
.
nil?
@too_large
=
@diff
.
bytesize
>=
SIZE_LIMIT
else
@too_large
end
end
def
too_large!
...
...
spec/helpers/blob_helper_spec.rb
浏览文件 @
ce869e39
...
...
@@ -168,21 +168,19 @@ describe BlobHelper do
controller
.
params
[
:id
]
=
File
.
join
(
'master'
,
blob
.
path
)
end
context
'for error :too_large'
do
context
'when the size limit can be overridden'
do
let
(
:blob
)
{
fake_blob
(
size:
2
.
megabytes
)
}
context
'for error :collapsed'
do
let
(
:blob
)
{
fake_blob
(
size:
2
.
megabytes
)
}
it
'includes a "load it anyway" link'
do
expect
(
helper
.
blob_render_error_options
(
viewer
)).
to
include
(
/load it anyway/
)
end
it
'includes a "load it anyway" link'
do
expect
(
helper
.
blob_render_error_options
(
viewer
)).
to
include
(
/load it anyway/
)
end
end
context
'when the size limit cannot be overridden
'
do
let
(
:blob
)
{
fake_blob
(
size:
10
.
megabytes
)
}
context
'for error :too_large
'
do
let
(
:blob
)
{
fake_blob
(
size:
10
.
megabytes
)
}
it
'does not include a "load it anyway" link'
do
expect
(
helper
.
blob_render_error_options
(
viewer
)).
not_to
include
(
/load it anyway/
)
end
it
'does not include a "load it anyway" link'
do
expect
(
helper
.
blob_render_error_options
(
viewer
)).
not_to
include
(
/load it anyway/
)
end
context
'when the viewer is rich'
do
...
...
spec/lib/gitlab/git/diff_spec.rb
浏览文件 @
ce869e39
...
...
@@ -85,12 +85,12 @@ EOT
# The patch total size is 200, with lines between 21 and 54.
# This is a quick-and-dirty way to test this. Ideally, a new patch is
# added to the test repo with a size that falls between the real limits.
stub_const
(
"
#{
described_class
}
::
MAX_SIZE
"
,
150
)
stub_const
(
"
#{
described_class
}
::
OVERRIDABLE_MAX_SIZE
"
,
100
)
stub_const
(
"
#{
described_class
}
::
SIZE_LIMIT
"
,
150
)
stub_const
(
"
#{
described_class
}
::
COLLAPSE_LIMIT
"
,
100
)
end
it
'prunes the diff as a large diff instead of as a collapsed diff'
do
diff
=
described_class
.
new
(
@rugged_diff
,
collapse:
tru
e
)
diff
=
described_class
.
new
(
@rugged_diff
,
expanded:
fals
e
)
expect
(
diff
.
diff
).
to
be_empty
expect
(
diff
).
to
be_too_large
...
...
@@ -299,15 +299,15 @@ EOT
describe
'#collapsed?'
do
it
'returns true for a diff that is quite large'
do
diff
=
described_class
.
new
(
diff:
'a'
*
20480
)
diff
=
described_class
.
new
(
{
diff:
'a'
*
20480
},
expanded:
false
)
expect
(
diff
).
to
be_collaps
ible
expect
(
diff
).
to
be_collaps
ed
end
it
'returns false for a diff that is small enough'
do
diff
=
described_class
.
new
(
diff:
'a'
)
diff
=
described_class
.
new
(
{
diff:
'a'
},
expanded:
false
)
expect
(
diff
).
not_to
be_collaps
ible
expect
(
diff
).
not_to
be_collaps
ed
end
end
...
...
spec/models/blob_viewer/base_spec.rb
浏览文件 @
ce869e39
...
...
@@ -105,36 +105,8 @@ describe BlobViewer::Base, model: true do
end
end
describe
'#can_expanded?'
do
context
'when the blob size is larger than the collapse limit'
do
context
'when the blob size is larger than the size limit'
do
let
(
:blob
)
{
fake_blob
(
path:
'file.pdf'
,
size:
10
.
megabytes
)
}
it
'returns false'
do
expect
(
viewer
.
can_expanded?
).
to
be_falsey
end
end
context
'when the blob size is smaller than the size limit'
do
let
(
:blob
)
{
fake_blob
(
path:
'file.pdf'
,
size:
2
.
megabytes
)
}
it
'returns true'
do
expect
(
viewer
.
can_expanded?
).
to
be_truthy
end
end
end
context
'when the blob size is smaller than the collapse limit'
do
let
(
:blob
)
{
fake_blob
(
path:
'file.pdf'
,
size:
10
.
kilobytes
)
}
it
'returns false'
do
expect
(
viewer
.
can_expanded?
).
to
be_falsey
end
end
end
describe
'#render_error'
do
context
'when
the size limit is overridden
'
do
context
'when
expanded
'
do
before
do
viewer
.
expanded
=
true
end
...
...
@@ -156,12 +128,12 @@ describe BlobViewer::Base, model: true do
end
end
context
'when
the size limit is not overridden
'
do
context
'when
not expanded
'
do
context
'when the blob size is larger than the collapse limit'
do
let
(
:blob
)
{
fake_blob
(
path:
'file.pdf'
,
size:
2
.
megabytes
)
}
it
'returns :
too_large
'
do
expect
(
viewer
.
render_error
).
to
eq
(
:
too_large
)
it
'returns :
collapsed
'
do
expect
(
viewer
.
render_error
).
to
eq
(
:
collapsed
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录