Welcome to mirror list, hosted at ThFree Co, Russian Federation.

quick_action_pipeline_spec.rb « pipeline « banzai « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cce69b9baf0e290b8c3b3757ada151896166aa35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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