diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 21:08:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 21:08:58 +0300 |
commit | 1ca9950d5f890cd8f185e1eda158b969a7244fe2 (patch) | |
tree | 6f62715938a4b2b001705c51c697609a8e0850ae /spec/presenters | |
parent | bcc77054ee9aefd1e332e04a4189390fd5a3112e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/snippet_blob_presenter_spec.rb | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/spec/presenters/snippet_blob_presenter_spec.rb b/spec/presenters/snippet_blob_presenter_spec.rb index 2a113e353c8..92893ec597a 100644 --- a/spec/presenters/snippet_blob_presenter_spec.rb +++ b/spec/presenters/snippet_blob_presenter_spec.rb @@ -18,7 +18,7 @@ describe SnippetBlobPresenter do snippet.file_name = 'test.md' snippet.content = '*foo*' - expect(subject).to eq '<p data-sourcepos="1:1-1:5" dir="auto"><em>foo</em></p>' + expect(subject).to eq '<span id="LC1" class="line" lang="markdown"><span class="ge">*foo*</span></span>' end it 'returns syntax highlighted content' do @@ -33,7 +33,41 @@ describe SnippetBlobPresenter do snippet.file_name = 'test' snippet.content = 'foo' - expect(described_class.new(snippet.blob).highlighted_data).to eq '<span id="LC1" class="line" lang="plaintext">foo</span>' + expect(subject).to eq '<span id="LC1" class="line" lang="plaintext">foo</span>' + end + end + + describe '#plain_highlighted_data' do + let(:snippet) { build(:personal_snippet) } + + subject { described_class.new(snippet.blob).plain_highlighted_data } + + it 'returns nil when the snippet blob is binary' do + allow(snippet.blob).to receive(:binary?).and_return(true) + + expect(subject).to be_nil + end + + it 'returns plain content when snippet file is markup' do + snippet.file_name = 'test.md' + snippet.content = '*foo*' + + expect(subject).to eq '<span id="LC1" class="line" lang="">*foo*</span>' + end + + it 'returns plain syntax content' do + snippet.file_name = 'test.rb' + snippet.content = 'class Foo;end' + + expect(subject) + .to eq '<span id="LC1" class="line" lang="">class Foo;end</span>' + end + + it 'returns plain text highlighted content' do + snippet.file_name = 'test' + snippet.content = 'foo' + + expect(subject).to eq '<span id="LC1" class="line" lang="">foo</span>' end end |