diff options
-rw-r--r-- | config/routes/group.rb | 14 | ||||
-rw-r--r-- | lib/gitlab/path_regex.rb | 1 | ||||
-rw-r--r-- | spec/routing/group_routing_spec.rb | 18 |
3 files changed, 28 insertions, 5 deletions
diff --git a/config/routes/group.rb b/config/routes/group.rb index f4d520a2518..ccd4ea7a8dd 100644 --- a/config/routes/group.rb +++ b/config/routes/group.rb @@ -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 diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb index 22f8dd669d0..5b9c60f945c 100644 --- a/lib/gitlab/path_regex.rb +++ b/lib/gitlab/path_regex.rb @@ -120,7 +120,6 @@ module Gitlab group_members hooks issues - labels ldap ldap_group_links merge_requests diff --git a/spec/routing/group_routing_spec.rb b/spec/routing/group_routing_spec.rb new file mode 100644 index 00000000000..39fbf082b4d --- /dev/null +++ b/spec/routing/group_routing_spec.rb @@ -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 |