2019-10-29 02:06:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-26 10:10:03 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
RSpec.shared_examples 'groups routing' do
|
|
|
|
let(:group_path) { 'projects.abc123' }
|
2017-10-26 11:49:07 -04:00
|
|
|
let!(:group) { create(:group, path: group_path) }
|
|
|
|
|
|
|
|
it "to #show" do
|
|
|
|
expect(get("/groups/#{group_path}")).to route_to('groups#show', id: group_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "also supports nested groups" do
|
|
|
|
nested_group = create(:group, parent: group)
|
|
|
|
expect(get("/#{group_path}/#{nested_group.path}")).to route_to('groups#show', id: "#{group_path}/#{nested_group.path}")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "also display group#show on the short path" do
|
|
|
|
expect(get("/#{group_path}")).to route_to('groups#show', id: group_path)
|
|
|
|
end
|
|
|
|
|
2019-03-14 08:55:46 -04:00
|
|
|
it "to #details" do
|
|
|
|
expect(get("/groups/#{group_path}/-/details")).to route_to('groups#details', id: group_path)
|
|
|
|
end
|
|
|
|
|
2017-10-26 11:49:07 -04:00
|
|
|
it "to #activity" do
|
2017-10-27 05:29:51 -04:00
|
|
|
expect(get("/groups/#{group_path}/-/activity")).to route_to('groups#activity', id: group_path)
|
2017-10-26 11:49:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "to #issues" do
|
2017-10-27 05:29:51 -04:00
|
|
|
expect(get("/groups/#{group_path}/-/issues")).to route_to('groups#issues', id: group_path)
|
2017-10-26 11:49:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "to #members" do
|
|
|
|
expect(get("/groups/#{group_path}/-/group_members")).to route_to('groups/group_members#index', group_id: group_path)
|
|
|
|
end
|
|
|
|
|
2017-10-27 05:29:51 -04:00
|
|
|
it "to #labels" do
|
|
|
|
expect(get("/groups/#{group_path}/-/labels")).to route_to('groups/labels#index', group_id: group_path)
|
|
|
|
end
|
2017-10-26 11:49:07 -04:00
|
|
|
|
2017-10-27 05:29:51 -04:00
|
|
|
it "to #milestones" do
|
|
|
|
expect(get("/groups/#{group_path}/-/milestones")).to route_to('groups/milestones#index', group_id: group_path)
|
|
|
|
end
|
2017-10-26 11:49:07 -04:00
|
|
|
|
2020-09-30 17:10:09 -04:00
|
|
|
it "to #runner_setup_scripts" do
|
|
|
|
expect(get("/groups/#{group_path}/-/settings/ci_cd/runner_setup_scripts")).to route_to('groups/settings/ci_cd#runner_setup_scripts', group_id: group_path)
|
|
|
|
end
|
|
|
|
|
2019-06-07 07:38:26 -04:00
|
|
|
it 'routes to the avatars controller' do
|
|
|
|
expect(delete("/groups/#{group_path}/-/avatar"))
|
|
|
|
.to route_to(group_id: group_path,
|
|
|
|
controller: 'groups/avatars',
|
|
|
|
action: 'destroy')
|
|
|
|
end
|
2019-04-26 00:11:47 -04:00
|
|
|
|
2019-06-07 07:38:26 -04:00
|
|
|
it 'routes to the boards controller' do
|
|
|
|
allow(Group).to receive(:find_by_full_path).with('gitlabhq', any_args).and_return(true)
|
2019-04-26 00:11:47 -04:00
|
|
|
|
2019-06-07 07:38:26 -04:00
|
|
|
expect(get('/groups/gitlabhq/-/boards')).to route_to('groups/boards#index', group_id: 'gitlabhq')
|
2017-10-26 10:10:03 -04:00
|
|
|
end
|
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
|
|
|
|
RSpec.describe "Groups", "routing" do
|
|
|
|
context 'complex group path with dot' do
|
|
|
|
include_examples 'groups routing' do
|
|
|
|
let(:group_path) { 'complex.group-namegit' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'group path starting with help' do
|
|
|
|
include_examples 'groups routing' do
|
|
|
|
let(:group_path) { 'help.abc123' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'group path starting with projects' do
|
|
|
|
include_examples 'groups routing' do
|
|
|
|
let(:group_path) { 'projects.abc123' }
|
|
|
|
end
|
|
|
|
end
|
2020-11-13 16:09:31 -05:00
|
|
|
|
|
|
|
describe 'dependency proxy for containers' do
|
2020-12-03 13:10:10 -05:00
|
|
|
it 'routes to #authenticate' do
|
|
|
|
expect(get('/v2')).to route_to('groups/dependency_proxy_auth#authenticate')
|
|
|
|
end
|
|
|
|
|
2020-11-13 16:09:31 -05:00
|
|
|
context 'image name without namespace' do
|
|
|
|
it 'routes to #manifest' do
|
|
|
|
expect(get('/v2/gitlabhq/dependency_proxy/containers/ruby/manifests/2.3.6'))
|
|
|
|
.to route_to('groups/dependency_proxy_for_containers#manifest', group_id: 'gitlabhq', image: 'ruby', tag: '2.3.6')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'routes to #blob' do
|
|
|
|
expect(get('/v2/gitlabhq/dependency_proxy/containers/ruby/blobs/abc12345'))
|
|
|
|
.to route_to('groups/dependency_proxy_for_containers#blob', group_id: 'gitlabhq', image: 'ruby', sha: 'abc12345')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not route to #blob with an invalid sha' do
|
|
|
|
expect(get('/v2/gitlabhq/dependency_proxy/containers/ruby/blobs/sha256:asdf1234%2f%2e%2e'))
|
|
|
|
.not_to route_to(group_id: 'gitlabhq', image: 'ruby', sha: 'sha256:asdf1234%2f%2e%2e')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not route to #blob with an invalid image' do
|
|
|
|
expect(get('/v2/gitlabhq/dependency_proxy/containers/ru*by/blobs/abc12345'))
|
|
|
|
.not_to route_to('groups/dependency_proxy_for_containers#blob', group_id: 'gitlabhq', image: 'ru*by', sha: 'abc12345')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'image name with namespace' do
|
|
|
|
it 'routes to #manifest' do
|
|
|
|
expect(get('/v2/gitlabhq/dependency_proxy/containers/foo/bar/manifests/2.3.6'))
|
|
|
|
.to route_to('groups/dependency_proxy_for_containers#manifest', group_id: 'gitlabhq', image: 'foo/bar', tag: '2.3.6')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'routes to #blob' do
|
|
|
|
expect(get('/v2/gitlabhq/dependency_proxy/containers/foo/bar/blobs/abc12345'))
|
|
|
|
.to route_to('groups/dependency_proxy_for_containers#blob', group_id: 'gitlabhq', image: 'foo/bar', sha: 'abc12345')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-07-08 08:09:33 -04:00
|
|
|
end
|