diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-08-05 12:44:13 +0300 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-08-06 04:32:29 +0300 |
commit | 46631e102366bd40bdb449b87fae3f10e992ee68 (patch) | |
tree | 7dd1ffe71cc632f8175c291638ff35d1f40613e3 /spec/lib/gitlab/highlight_spec.rb | |
parent | fa216b0e86433192ba4e39a05f42217fb4685173 (diff) |
Support selective highlighting of lines
Instead of highlighting all lines when not all of them are
needed, only highlight specific lines.
The `BlobPresenter#highlight` method has been updated to
support `since` and `to` params. These params will be used to
limit the content to be highlighted.
Modify `Gitlab::Highlight` to support `since` param which will
then be used to determine the starting line number.
Diffstat (limited to 'spec/lib/gitlab/highlight_spec.rb')
-rw-r--r-- | spec/lib/gitlab/highlight_spec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 4676db6b8d8..a410e4eab45 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -62,6 +62,14 @@ describe Gitlab::Highlight do expect(lines[2].text).to eq(' """') end + context 'since param is present' do + it 'highlights with the LC starting from "since" param' do + lines = described_class.highlight(file_name, content, since: 2).lines + + expect(lines[0]).to include('LC2') + end + end + context 'diff highlighting' do let(:file_name) { 'test.diff' } let(:content) { "+aaa\n+bbb\n- ccc\n ddd\n"} |