debian-mirror-gitlab/spec/lib/constraints/jira_encoded_url_constrainer_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.1 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'fast_spec_helper'
2020-11-24 15:15:51 +05:30
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