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>2020-02-10 12:08:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-10 12:08:56 +0300
commitb4ded0ba7b4d2cdbed5b1f331cf2083a25ee4d7c (patch)
tree6694fa9d8f3e226597cc01dfb8e3e07b50ae85b6 /spec/lib/banzai
parent2aaef94c80937d9d188f7b9cbbad2dcd1508c3c1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r--spec/lib/banzai/filter/gollum_tags_filter_spec.rb15
-rw-r--r--spec/lib/banzai/filter/table_of_contents_tag_filter_spec.rb23
-rw-r--r--spec/lib/banzai/pipeline/full_pipeline_spec.rb31
3 files changed, 54 insertions, 15 deletions
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
index 9d179ef2a49..1580177eaad 100644
--- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
@@ -100,19 +100,4 @@ describe Banzai::Filter::GollumTagsFilter do
expect(doc.at_css('code').text).to eq '[[link-in-backticks]]'
end
end
-
- context 'table of contents' do
- it 'replaces [[<em>TOC</em>]] with ToC result' do
- doc = described_class.call("<p>[[<em>TOC</em>]]</p>", { project_wiki: project_wiki }, { toc: "FOO" })
-
- expect(doc.to_html).to eq("FOO")
- end
-
- it 'handles an empty ToC result' do
- input = "<p>[[<em>TOC</em>]]</p>"
- doc = described_class.call(input, project_wiki: project_wiki)
-
- expect(doc.to_html).to eq ''
- end
- end
end
diff --git a/spec/lib/banzai/filter/table_of_contents_tag_filter_spec.rb b/spec/lib/banzai/filter/table_of_contents_tag_filter_spec.rb
new file mode 100644
index 00000000000..20f32d7347d
--- /dev/null
+++ b/spec/lib/banzai/filter/table_of_contents_tag_filter_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Banzai::Filter::TableOfContentsTagFilter do
+ include FilterSpecHelper
+
+ context 'table of contents' do
+ let(:html) { '<p>[[<em>TOC</em>]]</p>' }
+
+ it 'replaces [[<em>TOC</em>]] with ToC result' do
+ doc = filter(html, {}, { toc: "FOO" })
+
+ expect(doc.to_html).to eq("FOO")
+ end
+
+ it 'handles an empty ToC result' do
+ doc = filter(html)
+
+ expect(doc.to_html).to eq ''
+ end
+ end
+end
diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb
index f63b86d1451..4fa39da3eb4 100644
--- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb
@@ -99,4 +99,35 @@ describe Banzai::Pipeline::FullPipeline do
end
end
end
+
+ describe 'table of contents' do
+ let(:project) { create(:project, :public) }
+ let(:markdown) do
+ <<-MARKDOWN.strip_heredoc
+ [[_TOC_]]
+
+ # Header
+ MARKDOWN
+ end
+ let(:invalid_markdown) do
+ <<-MARKDOWN.strip_heredoc
+ test [[_TOC_]]
+
+ # Header
+ MARKDOWN
+ end
+
+ 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>")
+ end
+
+ it 'does not insert a table of contents' do
+ output = described_class.to_html(invalid_markdown, project: project)
+
+ expect(output).to include("test [[<em>TOC</em>]]")
+ end
+ end
end