diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/lib/banzai/pipeline/full_pipeline_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/lib/banzai/pipeline/full_pipeline_spec.rb')
-rw-r--r-- | spec/lib/banzai/pipeline/full_pipeline_spec.rb | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb index 989e06a992d..72661003361 100644 --- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb @@ -102,33 +102,45 @@ RSpec.describe Banzai::Pipeline::FullPipeline do describe 'table of contents' do let(:project) { create(:project, :public) } - let(:markdown) do - <<-MARKDOWN.strip_heredoc - [[_TOC_]] + + shared_examples 'table of contents tag' do |tag, tag_html| + let(:markdown) do + <<-MARKDOWN.strip_heredoc + #{tag} # Header - MARKDOWN - end + MARKDOWN + end - let(:invalid_markdown) do - <<-MARKDOWN.strip_heredoc - test [[_TOC_]] + let(:invalid_markdown) do + <<-MARKDOWN.strip_heredoc + test #{tag} # Header - MARKDOWN - end + MARKDOWN + end - it 'inserts a table of contents' do - output = described_class.to_html(markdown, project: project) + it 'inserts a table of contents' do + output = described_class.to_html(markdown, project: project) - expect(output).to include("<ul class=\"section-nav\">") - expect(output).to include("<li><a href=\"#header\">Header</a></li>") + expect(output).to include("<ul class=\"section-nav\">") + expect(output).to include("<li><a href=\"#header\">Header</a></li>") + end + + it 'does not insert a table of contents' do + output = described_class.to_html(invalid_markdown, project: project) + + expect(output).to include("test #{tag_html}") + end end - it 'does not insert a table of contents' do - output = described_class.to_html(invalid_markdown, project: project) + context 'with [[_TOC_]] as tag' do + it_behaves_like 'table of contents tag', '[[_TOC_]]', '[[<em>TOC</em>]]' + end - expect(output).to include("test [[<em>TOC</em>]]") + context 'with [toc] as tag' do + it_behaves_like 'table of contents tag', '[toc]', '[toc]' + it_behaves_like 'table of contents tag', '[TOC]', '[TOC]' end end |