diff --git a/changelogs/unreleased/dz-scope-snippet-routes.yml b/changelogs/unreleased/dz-scope-snippet-routes.yml new file mode 100644 index 0000000000000000000000000000000000000000..7e6fe32a19684bff56a9e494b7664475f43485a2 --- /dev/null +++ b/changelogs/unreleased/dz-scope-snippet-routes.yml @@ -0,0 +1,5 @@ +--- +title: Copy snippet route under - scope +merge_request: 35020 +author: +type: other diff --git a/config/routes.rb b/config/routes.rb index 598a52cddb350dedb0509a9bb7a28e9180b2e3b8..83db7ff8d4c57fc575814eda3b2fcf2eba598aab 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -262,6 +262,14 @@ draw :user draw :project + # Serve snippet routes under /-/snippets. + # To ensure an old unscoped routing is used for the UI we need to + # add prefix 'as' to the scope routing and place it below original routing. + # Issue https://gitlab.com/gitlab-org/gitlab/-/issues/210024 + scope '-', as: :scoped do + draw :snippets + end + root to: "root#index" get '*unmatched_route', to: 'application#route_not_found' diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 9c3d17f7d8fc724e20f171bcadcec4c29773b89d..982af3984f2f29b95a7ea1249025b78a9b252ae4 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -99,6 +99,10 @@ it "to #destroy" do expect(delete("/snippets/1")).to route_to('snippets#destroy', id: '1') end + + it 'to #show from scope routing' do + expect(get("/-/snippets/1")).to route_to('snippets#show', id: '1') + end end # help GET /help(.:format) help#index