diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-03-04 21:19:11 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-03-04 21:19:11 +0000 |
commit | 925da3fdf83b81014502f5a72191e940dd401f3c (patch) | |
tree | a0aba936d461d2ae041cd507b1d632cee8afdc36 /spec | |
parent | 3231ea10b7319f6fe50c0ec1407ddaac69089641 (diff) | |
parent | def6446dad808f2ff0f725df7a08f81365719586 (diff) | |
download | gitlab-ce-925da3fdf83b81014502f5a72191e940dd401f3c.tar.gz |
Merge branch 'rs-wiki-pipeline-spec' into 'master'
Add a spec for WikiPipeline
Removes the specs from GollumTagsFilter that were more like integration
tests for the pipeline than unit tests of the filter.
See merge request !3054
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/banzai/filter/gollum_tags_filter_spec.rb | 51 | ||||
-rw-r--r-- | spec/lib/banzai/pipeline/wiki_pipeline_spec.rb | 53 |
2 files changed, 60 insertions, 44 deletions
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index 11cc290d6d0..5e23c5c319a 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -88,54 +88,17 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do end context 'table of contents' do - let(:pipeline) { Banzai::Pipeline[:wiki] } + it 'replaces [[<em>TOC</em>]] with ToC result' do + doc = described_class.call("<p>[[<em>TOC</em>]]</p>", { project_wiki: project_wiki }, { toc: "FOO" }) - it 'replaces the tag with the TableOfContentsFilter result' do - markdown = <<-MD.strip_heredoc - [[_TOC_]] - - ## Header - - Foo - MD - - result = pipeline.call(markdown, project_wiki: project_wiki, project: project) - - aggregate_failures do - expect(result[:output].text).not_to include '[[_TOC_]]' - expect(result[:output].text).not_to include '[[' - expect(result[:output].to_html).to include(result[:toc]) - end - end - - it 'is case-sensitive' do - markdown = <<-MD.strip_heredoc - [[_toc_]] - - # Header 1 - - Foo - MD - - output = pipeline.to_html(markdown, project_wiki: project_wiki, project: project) - - expect(output).to include('[[<em>toc</em>]]') + expect(doc.to_html).to eq("FOO") end - it 'handles an empty pipeline result' do - # No Markdown headers in this doc, so `result[:toc]` will be empty - markdown = <<-MD.strip_heredoc - [[_TOC_]] - - Foo - MD - - output = pipeline.to_html(markdown, project_wiki: project_wiki, project: project) + it 'handles an empty ToC result' do + input = "<p>[[<em>TOC</em>]]</p>" + doc = described_class.call(input, project_wiki: project_wiki) - aggregate_failures do - expect(output).not_to include('<ul>') - expect(output).to include('[[<em>TOC</em>]]') - end + expect(doc.to_html).to eq '' end end end diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb new file mode 100644 index 00000000000..3e25406e498 --- /dev/null +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -0,0 +1,53 @@ +require 'rails_helper' + +describe Banzai::Pipeline::WikiPipeline do + describe 'TableOfContents' do + it 'replaces the tag with the TableOfContentsFilter result' do + markdown = <<-MD.strip_heredoc + [[_TOC_]] + + ## Header + + Foo + MD + + result = described_class.call(markdown, project: spy, project_wiki: double) + + aggregate_failures do + expect(result[:output].text).not_to include '[[' + expect(result[:output].text).not_to include 'TOC' + expect(result[:output].to_html).to include(result[:toc]) + end + end + + it 'is case-sensitive' do + markdown = <<-MD.strip_heredoc + [[_toc_]] + + # Header 1 + + Foo + MD + + output = described_class.to_html(markdown, project: spy, project_wiki: double) + + expect(output).to include('[[<em>toc</em>]]') + end + + it 'handles an empty pipeline result' do + # No Markdown headers in this doc, so `result[:toc]` will be empty + markdown = <<-MD.strip_heredoc + [[_TOC_]] + + Foo + MD + + output = described_class.to_html(markdown, project: spy, project_wiki: double) + + aggregate_failures do + expect(output).not_to include('<ul>') + expect(output).not_to include('[[<em>TOC</em>]]') + end + end + end +end |