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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f411b207
Commit
f411b207
authored
May 24, 2020
by
Rajendra Kadam
Committed by
Peter Leitzen
May 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leaky constant in diff collection spec
parent
f9bc8d20
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
22 deletions
+30
-22
.rubocop.yml
.rubocop.yml
+0
-1
changelogs/unreleased/leaky-constant-fix-36.yml
changelogs/unreleased/leaky-constant-fix-36.yml
+5
-0
spec/lib/gitlab/git/diff_collection_spec.rb
spec/lib/gitlab/git/diff_collection_spec.rb
+25
-21
No files found.
.rubocop.yml
View file @
f411b207
...
@@ -351,7 +351,6 @@ RSpec/LeakyConstantDeclaration:
...
@@ -351,7 +351,6 @@ RSpec/LeakyConstantDeclaration:
-
'
spec/db/schema_spec.rb'
-
'
spec/db/schema_spec.rb'
-
'
spec/lib/feature_spec.rb'
-
'
spec/lib/feature_spec.rb'
-
'
spec/lib/gitlab/config/entry/simplifiable_spec.rb'
-
'
spec/lib/gitlab/config/entry/simplifiable_spec.rb'
-
'
spec/lib/gitlab/git/diff_collection_spec.rb'
-
'
spec/lib/gitlab/import_export/import_test_coverage_spec.rb'
-
'
spec/lib/gitlab/import_export/import_test_coverage_spec.rb'
-
'
spec/lib/gitlab/quick_actions/dsl_spec.rb'
-
'
spec/lib/gitlab/quick_actions/dsl_spec.rb'
-
'
spec/lib/marginalia_spec.rb'
-
'
spec/lib/marginalia_spec.rb'
...
...
changelogs/unreleased/leaky-constant-fix-36.yml
0 → 100644
View file @
f411b207
---
title
:
Fix leaky constant issue in diff collection spec
merge_request
:
32163
author
:
Rajendra Kadam
type
:
fixed
spec/lib/gitlab/git/diff_collection_spec.rb
View file @
f411b207
...
@@ -3,6 +3,31 @@
...
@@ -3,6 +3,31 @@
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Git
::
DiffCollection
,
:seed_helper
do
describe
Gitlab
::
Git
::
DiffCollection
,
:seed_helper
do
before
do
stub_const
(
'MutatingConstantIterator'
,
Class
.
new
)
MutatingConstantIterator
.
class_eval
do
include
Enumerable
def
initialize
(
count
,
value
)
@count
=
count
@value
=
value
end
def
each
return
enum_for
(
:each
)
unless
block_given?
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
subject
do
subject
do
Gitlab
::
Git
::
DiffCollection
.
new
(
Gitlab
::
Git
::
DiffCollection
.
new
(
iterator
,
iterator
,
...
@@ -659,25 +684,4 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
...
@@ -659,25 +684,4 @@ describe Gitlab::Git::DiffCollection, :seed_helper 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
return
enum_for
(
:each
)
unless
block_given?
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