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:
Diffstat (limited to 'spec/lib/banzai/pipeline/quick_action_pipeline_spec.rb')
-rw-r--r--spec/lib/banzai/pipeline/quick_action_pipeline_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/lib/banzai/pipeline/quick_action_pipeline_spec.rb b/spec/lib/banzai/pipeline/quick_action_pipeline_spec.rb
new file mode 100644
index 00000000000..cce69b9baf0
--- /dev/null
+++ b/spec/lib/banzai/pipeline/quick_action_pipeline_spec.rb
@@ -0,0 +1,62 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Banzai::Pipeline::QuickActionPipeline, feature_category: :team_planning do
+ using RSpec::Parameterized::TableSyntax
+
+ it 'does not detect a quick action' do
+ markdown = <<~MD.strip
+ <!-- HTML comment -->
+ A paragraph
+
+ > a blockquote
+ MD
+ result = described_class.call(markdown, project: nil)
+
+ expect(result[:quick_action_paragraphs]).to be_empty
+ end
+
+ it 'does detect a quick action' do
+ markdown = <<~MD.strip
+ <!-- HTML comment -->
+ /quick
+
+ > a blockquote
+ MD
+ result = described_class.call(markdown, project: nil)
+
+ expect(result[:quick_action_paragraphs]).to match_array [{ start_line: 1, end_line: 1 }]
+ end
+
+ it 'does detect a multiple quick actions but not in a multi-line blockquote' do
+ markdown = <<~MD.strip
+ Lorem ipsum
+ /quick
+ /action
+
+ >>>
+ /quick
+ >>>
+
+ /action
+ MD
+ result = described_class.call(markdown, project: nil)
+
+ expect(result[:quick_action_paragraphs])
+ .to match_array [{ start_line: 0, end_line: 2 }, { start_line: 8, end_line: 8 }]
+ end
+
+ it 'does not a quick action in a code block' do
+ markdown = <<~MD.strip
+ ```
+ Lorem ipsum
+ /quick
+ /action
+ ```
+ MD
+ result = described_class.call(markdown, project: nil)
+
+ expect(result[:quick_action_paragraphs]).to be_empty
+ end
+end