Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-09-02 06:19:32 +0300
committerPatrick Bajao <ebajao@gitlab.com>2019-09-02 06:44:45 +0300
commitbf230da05d8a3a6feeeb80d81fa0370cc295478e (patch)
treecaefbfda883d3360cb2aea07a5ea925447e39a5b /spec/presenters
parent60adc14473911fd9bd33feef2fbfd62a9824a11c (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.rb14
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')