diff options
Diffstat (limited to 'spec/lib/banzai/pipeline')
9 files changed, 74 insertions, 8 deletions
diff --git a/spec/lib/banzai/pipeline/broadcast_message_pipeline_spec.rb b/spec/lib/banzai/pipeline/broadcast_message_pipeline_spec.rb index 9832b132b58..41a91c56f3b 100644 --- a/spec/lib/banzai/pipeline/broadcast_message_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/broadcast_message_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::BroadcastMessagePipeline do +RSpec.describe Banzai::Pipeline::BroadcastMessagePipeline do before do stub_commonmark_sourcepos_disabled end diff --git a/spec/lib/banzai/pipeline/description_pipeline_spec.rb b/spec/lib/banzai/pipeline/description_pipeline_spec.rb index 6778a273bba..82d4f883e0d 100644 --- a/spec/lib/banzai/pipeline/description_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/description_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::DescriptionPipeline do +RSpec.describe Banzai::Pipeline::DescriptionPipeline do let_it_be(:project) { create(:project) } def parse(html) diff --git a/spec/lib/banzai/pipeline/email_pipeline_spec.rb b/spec/lib/banzai/pipeline/email_pipeline_spec.rb index 77186861225..c7a0b9fefa1 100644 --- a/spec/lib/banzai/pipeline/email_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/email_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::EmailPipeline do +RSpec.describe Banzai::Pipeline::EmailPipeline do describe '.filters' do it 'returns the expected type' do expect(described_class.filters).to be_kind_of(Banzai::FilterArray) diff --git a/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb b/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb index 744df3e0b96..6de9d65f1b2 100644 --- a/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::EmojiPipeline do +RSpec.describe Banzai::Pipeline::EmojiPipeline do def parse(text) described_class.to_html(text, {}) end diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb index b4047e369fb..0127ac11c81 100644 --- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::FullPipeline do +RSpec.describe Banzai::Pipeline::FullPipeline do describe 'References' do let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } diff --git a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb index 448422b15e3..beb760637b0 100644 --- a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb @@ -2,12 +2,63 @@ require 'spec_helper' -describe Banzai::Pipeline::GfmPipeline do +RSpec.describe Banzai::Pipeline::GfmPipeline do describe 'integration between parsing regular and external issue references' do let(:project) { create(:redmine_project, :public) } context 'when internal issue tracker is enabled' do context 'when shorthand pattern #ISSUE_ID is used' do + it 'links an internal issues and keep updated nodes in result[:reference_filter_nodes]', :aggregate_failures do + issue = create(:issue, project: project) + markdown = "text #{issue.to_reference(project, full: true)}" + + result = described_class.call(markdown, project: project) + link = result[:output].css('a').first + text = result[:output].children.first + + expect(link['href']).to eq(Gitlab::Routing.url_helpers.project_issue_path(project, issue)) + expect(result[:reference_filter_nodes]).to eq([text]) + end + end + + it 'executes :each_node only once for first reference filter', :aggregate_failures do + issue = create(:issue, project: project) + markdown = "text #{issue.to_reference(project, full: true)}" + + expect_any_instance_of(Banzai::Filter::ReferenceFilter).to receive(:each_node).once + + described_class.call(markdown, project: project) + end + + context "with update_nodes_for_banzai_reference_filter feature flag disabled" do + before do + stub_feature_flags(update_nodes_for_banzai_reference_filter: false) + end + + context 'when shorthand pattern #ISSUE_ID is used' do + it 'links an internal issues and doesnt store nodes in result[:reference_filter_nodes]', :aggregate_failures do + issue = create(:issue, project: project) + markdown = "text #{issue.to_reference(project, full: true)}" + result = described_class.call(markdown, project: project) + link = result[:output].css('a').first + + expect(link['href']).to eq(Gitlab::Routing.url_helpers.project_issue_path(project, issue)) + expect(result[:reference_filter_nodes]).to eq nil + end + end + + it 'execute :each_node for each reference_filter', :aggregate_failures do + issue = create(:issue, project: project) + markdown = "text #{issue.to_reference(project, full: true)}" + described_class.reference_filters do |reference_filter| + expect_any_instance_of(reference_filter).to receive(:each_node).once + end + + described_class.call(markdown, project: project) + end + end + + context 'when shorthand pattern #ISSUE_ID is used' do it 'links an internal issue if it exists' do issue = create(:issue, project: project) markdown = issue.to_reference(project, full: true) diff --git a/spec/lib/banzai/pipeline/jira_import/adf_commonmark_pipeline_spec.rb b/spec/lib/banzai/pipeline/jira_import/adf_commonmark_pipeline_spec.rb new file mode 100644 index 00000000000..d8841a9753e --- /dev/null +++ b/spec/lib/banzai/pipeline/jira_import/adf_commonmark_pipeline_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Banzai::Pipeline::JiraImport::AdfCommonmarkPipeline do + let_it_be(:fixtures_path) { 'lib/kramdown/atlassian_document_format' } + + it 'converts text in Atlassian Document Format ' do + source = fixture_file(File.join(fixtures_path, 'paragraph.json')) + target = fixture_file(File.join(fixtures_path, 'paragraph.md')) + output = described_class.call(source, {})[:output] + + expect(output).to eq target + end +end diff --git a/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb b/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb index ab72354edcf..d9f45769550 100644 --- a/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::PostProcessPipeline do +RSpec.describe Banzai::Pipeline::PostProcessPipeline do context 'when a document only has upload links' do it 'does not make any Gitaly calls', :request_store do markdown = <<-MARKDOWN.strip_heredoc diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb index b2c24284eb9..4af782c7d73 100644 --- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Banzai::Pipeline::WikiPipeline do +RSpec.describe Banzai::Pipeline::WikiPipeline do let_it_be(:namespace) { create(:namespace, name: "wiki_link_ns") } let_it_be(:project) { create(:project, :public, name: "wiki_link_project", namespace: namespace) } let_it_be(:wiki) { ProjectWiki.new(project, double(:user)) } |