Free up `labels` as a group name

This commit is contained in:
Bob Van Landuyt 2017-10-26 16:10:03 +02:00
parent 414c4e3fd8
commit 5d14337baf
3 changed files with 28 additions and 5 deletions

View File

@ -34,10 +34,6 @@ constraints(GroupUrlConstrainer.new) do
end
end
resources :labels, except: [:show] do
post :toggle_subscription, on: :member
end
scope path: '-' do
namespace :settings do
resource :ci_cd, only: [:show], controller: 'ci_cd'
@ -46,6 +42,10 @@ constraints(GroupUrlConstrainer.new) do
resources :variables, only: [:index, :show, :update, :create, :destroy]
resources :children, only: [:index]
resources :labels, except: [:show] do
post :toggle_subscription, on: :member
end
end
end
@ -58,4 +58,10 @@ constraints(GroupUrlConstrainer.new) do
put '/', action: :update
delete '/', action: :destroy
end
# Legacy paths should be defined last, so they would be ignored if routes with
# one of the previously reserved words exist.
scope(path: 'groups/*group_id') do
Gitlab::Routing.redirect_legacy_paths(self, :labels)
end
end

View File

@ -120,7 +120,6 @@ module Gitlab
group_members
hooks
issues
labels
ldap
ldap_group_links
merge_requests

View File

@ -0,0 +1,18 @@
require 'spec_helper'
describe 'group routing' do
let!(:existing_group) { create(:group, parent: create(:group, path: 'gitlab-org'), path: 'infra') }
describe 'GET #labels' do
it 'routes to the correct controller' do
expect(get('/groups/gitlab-org/infra/-/labels'))
.to route_to(group_id: 'gitlab-org/infra',
controller: 'groups/labels',
action: 'index')
end
it_behaves_like 'redirecting a legacy path', '/groups/gitlab-org/infra/labels', '/groups/gitlab-org/infra/-/labels' do
let(:resource) { create(:group, parent: existing_group, path: 'labels') }
end
end
end