diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/lib/banzai/pipeline/gfm_pipeline_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib/banzai/pipeline/gfm_pipeline_spec.rb')
-rw-r--r-- | spec/lib/banzai/pipeline/gfm_pipeline_spec.rb | 53 |
1 files changed, 52 insertions, 1 deletions
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) |