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
Jérome Perrin
gitlab-ce
Commits
fcdc4279
Commit
fcdc4279
authored
May 23, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test that shows DiffCollection restart bug
parent
48422b41
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
3 deletions
+37
-3
spec/lib/gitlab/git/diff_collection_spec.rb
spec/lib/gitlab/git/diff_collection_spec.rb
+37
-3
No files found.
spec/lib/gitlab/git/diff_collection_spec.rb
View file @
fcdc4279
...
@@ -10,7 +10,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -10,7 +10,7 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
no_collapse:
no_collapse
no_collapse:
no_collapse
)
)
end
end
let
(
:iterator
)
{
Array
.
new
(
file_count
,
fake_diff
(
line_length
,
line_count
))
}
let
(
:iterator
)
{
MutatingConstantIterator
.
new
(
file_count
,
fake_diff
(
line_length
,
line_count
))
}
let
(
:file_count
)
{
0
}
let
(
:file_count
)
{
0
}
let
(
:line_length
)
{
1
}
let
(
:line_length
)
{
1
}
let
(
:line_count
)
{
1
}
let
(
:line_count
)
{
1
}
...
@@ -64,8 +64,16 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -64,8 +64,16 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
subject
{
super
().
real_size
}
subject
{
super
().
real_size
}
it
{
is_expected
.
to
eq
(
'3'
)
}
it
{
is_expected
.
to
eq
(
'3'
)
}
end
end
describe
'#size'
do
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
'does not change after peeking'
do
subject
.
any?
expect
(
subject
.
size
).
to
eq
(
3
)
end
end
context
'when limiting is disabled'
do
context
'when limiting is disabled'
do
let
(
:all_diffs
)
{
true
}
let
(
:all_diffs
)
{
true
}
...
@@ -83,7 +91,15 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -83,7 +91,15 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
subject
{
super
().
real_size
}
subject
{
super
().
real_size
}
it
{
is_expected
.
to
eq
(
'3'
)
}
it
{
is_expected
.
to
eq
(
'3'
)
}
end
end
describe
'#size'
do
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
{
expect
(
subject
.
size
).
to
eq
(
3
)
}
it
'does not change after peeking'
do
subject
.
any?
expect
(
subject
.
size
).
to
eq
(
3
)
end
end
end
end
end
end
...
@@ -457,4 +473,22 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
...
@@ -457,4 +473,22 @@ describe Gitlab::Git::DiffCollection, seed_helper: true do
def
fake_diff
(
line_length
,
line_count
)
def
fake_diff
(
line_length
,
line_count
)
{
'diff'
=>
"
#{
'a'
*
line_length
}
\n
"
*
line_count
}
{
'diff'
=>
"
#{
'a'
*
line_length
}
\n
"
*
line_count
}
end
end
class
MutatingConstantIterator
include
Enumerable
def
initialize
(
count
,
value
)
@count
=
count
@value
=
value
end
def
each
loop
do
break
if
@count
.
zero?
# It is critical to decrement before yielding. We may never reach the lines after 'yield'.
@count
-=
1
yield
@value
end
end
end
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