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

jira_encoded_url_constrainer_spec.rb « constraints « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f01703033cc6ce0b799be8ae5876618d6f42be63 (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
# frozen_string_literal: true

require 'fast_spec_helper'

RSpec.describe Constraints::JiraEncodedUrlConstrainer do
  let(:namespace_id) { 'group' }
  let(:project_id) { 'project' }
  let(:path) { "/#{namespace_id}/#{project_id}" }
  let(:request) { double(:request, path: path, params: { namespace_id: namespace_id, project_id: project_id }) }

  describe '#matches?' do
    subject { described_class.new.matches?(request) }

    context 'when there is no /-/jira prefix and no encoded slash' do
      it { is_expected.to eq(false) }
    end

    context 'when tree path contains encoded slash' do
      let(:path) { "/#{namespace_id}/#{project_id}/tree/folder-with-#{Gitlab::Jira::Dvcs::ENCODED_SLASH}" }

      it { is_expected.to eq(false) }
    end

    context 'when path has /-/jira prefix' do
      let(:path) { "/-/jira/#{namespace_id}/#{project_id}" }

      it { is_expected.to eq(true) }
    end

    context 'when project_id has encoded slash' do
      let(:project_id) { "sub_group#{Gitlab::Jira::Dvcs::ENCODED_SLASH}sub_project" }

      it { is_expected.to eq(true) }
    end
  end
end