diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/git/diff_collection_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/git/diff_collection_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/diff_collection_spec.rb | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb index 0d19d35bc52..6aa4f884d20 100644 --- a/spec/lib/gitlab/git/diff_collection_spec.rb +++ b/spec/lib/gitlab/git/diff_collection_spec.rb @@ -3,6 +3,31 @@ require 'spec_helper' 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 Gitlab::Git::DiffCollection.new( iterator, @@ -659,25 +684,4 @@ describe Gitlab::Git::DiffCollection, :seed_helper do def fake_diff(line_length, line_count) { 'diff' => "#{'a' * line_length}\n" * line_count } 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 |