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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-03 12:15:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-03 12:15:56 +0300
commit42d930072f05883b7b1b0cc060c175912ea942dc (patch)
treeac01c86680503b3378dd3a05208927f41d40a6c0 /spec/lib/banzai/pipeline
parent139f9c7dc18372bc4cdfaab5f887eae5e3547fa5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/banzai/pipeline')
-rw-r--r--spec/lib/banzai/pipeline/full_pipeline_spec.rb46
-rw-r--r--spec/lib/banzai/pipeline/wiki_pipeline_spec.rb19
2 files changed, 45 insertions, 20 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
diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
index 007d310247b..59f5e4a6900 100644
--- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe Banzai::Pipeline::WikiPipeline do
end
end
- it 'is case-sensitive' do
+ it 'is not case-sensitive' do
markdown = <<-MD.strip_heredoc
[[_toc_]]
@@ -36,9 +36,22 @@ RSpec.describe Banzai::Pipeline::WikiPipeline do
Foo
MD
- output = described_class.to_html(markdown, project: project, wiki: wiki)
+ result = described_class.call(markdown, project: project, wiki: wiki)
+
+ expect(result[:output].to_html).to include(result[:toc])
+ end
+
+ it 'works with alternative [toc] tag' do
+ markdown = <<-MD.strip_heredoc
+ [toc]
- expect(output).to include('[[<em>toc</em>]]')
+ # Header 1
+
+ Foo
+ MD
+
+ result = described_class.call(markdown, project: project, wiki: wiki)
+ expect(result[:output].to_html).to include(result[:toc])
end
it 'handles an empty pipeline result' do