diff options
author | Valery Sizov <valery@gitlab.com> | 2017-10-12 18:59:02 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-10-15 17:00:36 +0300 |
commit | d09895a0de015073301296597085d8c376870513 (patch) | |
tree | 31d70b0c589c60e5455b55502f149207ed049a40 /spec/lib/gitlab/diff | |
parent | 1e4b75ba40570a3e96e1999e375a120c4ba8b346 (diff) |
Fix diff parser so it tolerates to diff special markers in the content
Diffstat (limited to 'spec/lib/gitlab/diff')
-rw-r--r-- | spec/lib/gitlab/diff/parser_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/gitlab/diff/parser_spec.rb b/spec/lib/gitlab/diff/parser_spec.rb index 8af49ed50ff..80c8c189665 100644 --- a/spec/lib/gitlab/diff/parser_spec.rb +++ b/spec/lib/gitlab/diff/parser_spec.rb @@ -143,4 +143,21 @@ eos it { expect(parser.parse([])).to eq([]) } it { expect(parser.parse(nil)).to eq([]) } end + + describe 'tolerates special diff markers in a content' do + it "counts lines correctly" do + diff = <<~END + --- a/test + +++ b/test + @@ -1,2 +1,2 @@ + +ipsum + +++ b + -ipsum + END + + lines = parser.parse(diff.lines).to_a + + expect(lines.size).to eq(3) + end + end end |