diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-09-02 06:19:32 +0300 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-09-02 06:44:45 +0300 |
commit | bf230da05d8a3a6feeeb80d81fa0370cc295478e (patch) | |
tree | caefbfda883d3360cb2aea07a5ea925447e39a5b /spec/presenters | |
parent | 60adc14473911fd9bd33feef2fbfd62a9824a11c (diff) |
Support selective highlighting of lines
Instead of highlighting all lines when not all of them
are needed, only highlight from the beginning up to
the specified limit.
The `BlobPresenter#highlight` method has been updated
to support `to` param. This param will be used to limit
the content to be highlighted.
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/blob_presenter_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index eacf383be7d..8680e8b9b45 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -39,6 +39,20 @@ describe BlobPresenter, :seed_helper do subject.highlight(plain: true) end + context '"to" param is present' do + before do + allow(git_blob) + .to receive(:data) + .and_return("line one\nline two\nline 3") + end + + it 'returns limited highlighted content' do + expect(Gitlab::Highlight).to receive(:highlight).with('files/ruby/regex.rb', "line one\n", plain: nil, language: nil) + + subject.highlight(to: 1) + end + end + context 'gitlab-language contains a match' do before do allow(blob).to receive(:language_from_gitattributes).and_return('ruby') |