summaryrefslogtreecommitdiff
path: root/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
blob: 1eb90dc1847454757ffeccde950c28e2358b7220 (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
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.project_issue_path(other_project, issue)
      )
    end
  end
end