summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
blob: 2b8c76f2bb8f49890fa85e0359e4e12e36f98f76 (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
require 'rails_helper'

describe Banzai::Pipeline::GfmPipeline do
  describe 'integration between parsing regular and external issue references' do
    let(:project) { create(:redmine_project, :public) }

    it 'allows to use shorthand external reference syntax for Redmine' do
      markdown = '#12'

      result = described_class.call(markdown, project: project)[:output]
      link = result.css('a').first

      expect(link['href']).to eq 'http://redmine/projects/project_name_in_redmine/issues/12'
    end

    it 'parses cross-project references to regular issues' do
      other_project = create(:empty_project, :public)
      issue = create(:issue, project: other_project)
      markdown = issue.to_reference(project, full: true)

      result = described_class.call(markdown, project: project)[:output]
      link = result.css('a').first

      expect(link['href']).to eq(
        Gitlab::Routing.url_helpers.namespace_project_issue_path(
          other_project.namespace,
          other_project,
          issue
        )
      )
    end
  end
end