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
164c6374
Commit
164c6374
authored
Jan 08, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken specs. #3945
parent
78d7c0e0
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
87 deletions
+86
-87
spec/fixtures/parallel_diff_result.yml
spec/fixtures/parallel_diff_result.yml
+77
-79
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+9
-8
No files found.
spec/fixtures/parallel_diff_result.yml
View file @
164c6374
This diff is collapsed.
Click to expand it.
spec/helpers/diff_helper_spec.rb
View file @
164c6374
...
...
@@ -4,11 +4,12 @@ describe DiffHelper do
include
RepoHelpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diffs
)
{
commit
.
diffs
}
let
(
:diff
)
{
diffs
.
first
}
let
(
:diff_refs
)
{
[
commit
.
parent
.
id
,
commit
.
id
]
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
,
project
.
repository
)
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
,
repository
)
}
describe
'diff_hard_limit_enabled?'
do
it
'should return true if param is provided'
do
...
...
@@ -45,41 +46,41 @@ describe DiffHelper do
describe
'safe_diff_files'
do
it
'should return all files from a commit that is smaller than safe limits'
do
expect
(
safe_diff_files
(
diffs
).
length
).
to
eq
(
2
)
expect
(
safe_diff_files
(
diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
2
)
end
it
'should return only the first file if the diff line count in the 2nd file takes the total beyond safe limits'
do
allow
(
diffs
[
1
].
diff
).
to
receive
(
:lines
).
and_return
([
""
]
*
4999
)
#simulate 4999 lines
expect
(
safe_diff_files
(
diffs
).
length
).
to
eq
(
1
)
expect
(
safe_diff_files
(
diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
1
)
end
it
'should return all files from a commit that is beyond safe limit for numbers of lines if force diff is true'
do
allow
(
controller
).
to
receive
(
:params
)
{
{
force_show_diff:
true
}
}
allow
(
diffs
[
1
].
diff
).
to
receive
(
:lines
).
and_return
([
""
]
*
4999
)
#simulate 4999 lines
expect
(
safe_diff_files
(
diffs
).
length
).
to
eq
(
2
)
expect
(
safe_diff_files
(
diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
2
)
end
it
'should return only the first file if the diff line count in the 2nd file takes the total beyond hard limits'
do
allow
(
controller
).
to
receive
(
:params
)
{
{
force_show_diff:
true
}
}
allow
(
diffs
[
1
].
diff
).
to
receive
(
:lines
).
and_return
([
""
]
*
49999
)
#simulate 49999 lines
expect
(
safe_diff_files
(
diffs
).
length
).
to
eq
(
1
)
expect
(
safe_diff_files
(
diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
1
)
end
it
'should return only a safe number of file diffs if a commit touches more files than the safe limits'
do
large_diffs
=
diffs
*
100
#simulate 200 diffs
expect
(
safe_diff_files
(
large_diffs
).
length
).
to
eq
(
100
)
expect
(
safe_diff_files
(
large_diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
100
)
end
it
'should return all file diffs if a commit touches more files than the safe limits but force diff is true'
do
allow
(
controller
).
to
receive
(
:params
)
{
{
force_show_diff:
true
}
}
large_diffs
=
diffs
*
100
#simulate 200 diffs
expect
(
safe_diff_files
(
large_diffs
).
length
).
to
eq
(
200
)
expect
(
safe_diff_files
(
large_diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
200
)
end
it
'should return a limited file diffs if a commit touches more files than the hard limits and force diff is true'
do
allow
(
controller
).
to
receive
(
:params
)
{
{
force_show_diff:
true
}
}
very_large_diffs
=
diffs
*
1000
#simulate 2000 diffs
expect
(
safe_diff_files
(
very_large_diffs
).
length
).
to
eq
(
1000
)
expect
(
safe_diff_files
(
very_large_diffs
,
diff_refs
,
repository
).
length
).
to
eq
(
1000
)
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