2016-10-06 09:59:22 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GroupUrlConstrainer, lib: true do
|
2016-11-07 08:16:04 -05:00
|
|
|
let!(:group) { create(:group, path: 'gitlab') }
|
2016-10-06 09:59:22 -04:00
|
|
|
|
2016-11-07 08:16:04 -05:00
|
|
|
describe '#matches?' do
|
2016-11-14 09:55:31 -05:00
|
|
|
context 'valid request' do
|
|
|
|
let(:request) { build_request(group.path) }
|
|
|
|
|
|
|
|
it { expect(subject.matches?(request)).to be_truthy }
|
|
|
|
end
|
|
|
|
|
2016-10-31 07:00:53 -04:00
|
|
|
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
|
|
|
|
|
2016-11-14 09:55:31 -05:00
|
|
|
context 'invalid request' do
|
|
|
|
let(:request) { build_request('foo') }
|
|
|
|
|
|
|
|
it { expect(subject.matches?(request)).to be_falsey }
|
2016-11-07 08:16:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-14 09:55:31 -05:00
|
|
|
def build_request(path)
|
|
|
|
double(:request, params: { id: path })
|
2016-10-06 09:59:22 -04:00
|
|
|
end
|
|
|
|
end
|