Commit d2f9850f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Copy project snippet routes under - scope

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent cab25d36
---
title: Copy project snippet routes under - scope
merge_request: 35022
author:
type: other
...@@ -369,6 +369,19 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -369,6 +369,19 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
# 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/29572
scope '-', as: :scoped do
resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope
member do
get :raw
post :mark_as_spam
end
end
end
namespace :prometheus do namespace :prometheus do
resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do # rubocop: disable Cop/PutProjectRoutesUnderScope resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do # rubocop: disable Cop/PutProjectRoutesUnderScope
post :notify, on: :collection post :notify, on: :collection
......
...@@ -407,6 +407,10 @@ describe 'project routing' do ...@@ -407,6 +407,10 @@ describe 'project routing' do
it 'to #destroy' do it 'to #destroy' do
expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end end
it 'to #show from scope routing' do
expect(get('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
end end
# test_project_hook POST /:project_id/hooks/:id/test(.:format) hooks#test # test_project_hook POST /:project_id/hooks/:id/test(.:format) hooks#test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment