group_url_constrainer_spec.rb 777 Bytes
Newer Older
1
2
3
require 'spec_helper'

describe GroupUrlConstrainer, lib: true do
4
  let!(:group) { create(:group, path: 'gitlab') }
5

6
  describe '#matches?' do
7
8
9
10
11
12
    context 'valid request' do
      let(:request) { build_request(group.path) }

      it { expect(subject.matches?(request)).to be_truthy }
    end

13
14
15
16
17
18
19
    context 'valid request for nested group' do
      let!(:nested_group) { create(:group, path: 'nested', parent: group) }
      let!(:request) { build_request('gitlab/nested') }

      it { expect(subject.matches?(request)).to be_truthy }
    end

20
21
22
23
    context 'invalid request' do
      let(:request) { build_request('foo') }

      it { expect(subject.matches?(request)).to be_falsey }
24
25
26
    end
  end

27
28
  def build_request(path)
    double(:request, params: { id: path })
29
30
  end
end