Commit 19cbec3e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Redirect deprecated snippets routes

Redirect unscoped snippet routes like:
* /group/project/snippets -> /group/project/-/snippets
* /snippets/1 -> /-/snippets/1

Changelog: removed
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 4fbfaff7
......@@ -311,9 +311,13 @@ Rails.application.routes.draw do
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/210024
scope as: 'deprecated' do
draw :snippets
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/223719
get '/snippets/:id/raw',
to: 'snippets#raw',
format: false,
constraints: { id: /\d+/ }
Gitlab::Routing.redirect_legacy_paths(self, :profile)
Gitlab::Routing.redirect_legacy_paths(self, :profile, :snippets)
end
Gitlab.ee do
......
......@@ -568,13 +568,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
draw :repository
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/29572
resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope
member do
get :raw # rubocop:todo Cop/PutProjectRoutesUnderScope
post :mark_as_spam # rubocop:todo Cop/PutProjectRoutesUnderScope
end
end
# Issue https://gitlab.com/gitlab-org/gitlab/-/issues/223719
# rubocop: disable Cop/PutProjectRoutesUnderScope
get '/snippets/:id/raw',
to: 'snippets#raw',
format: false,
constraints: { id: /\d+/ }
# rubocop: enable Cop/PutProjectRoutesUnderScope
end
# All new routes should go under /-/ scope.
......@@ -589,7 +589,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
:tracing,
:serverless, :clusters, :audit_events, :wikis, :merge_requests,
:vulnerability_feedback, :security, :dependencies, :issues,
:pipelines, :pipeline_schedules)
:pipelines, :pipeline_schedules, :snippets)
end
# rubocop: disable Cop/PutProjectRoutesUnderScope
......
......@@ -113,7 +113,7 @@ RSpec.describe Gitlab::PathRegex do
let(:deprecated_routes) do
# profile was deprecated in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51646
%w(profile)
%w(profile s)
end
let(:ee_top_level_words) do
......
......@@ -310,9 +310,11 @@ RSpec.describe 'project routing' do
expect(get('/gitlab/gitlabhq/-/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it 'to #show from unscope routing' do
expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
it 'to #raw from unscope routing' do
expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it_behaves_like 'redirecting a legacy path', '/gitlab/gitlabhq/snippets/1', '/gitlab/gitlabhq/-/snippets/1'
end
# test_project_hook POST /:project_id/-/hooks/:id/test(.:format) hooks#test
......
......@@ -96,9 +96,11 @@ RSpec.describe SnippetsController, "routing" do
expect(get("/-/snippets/1")).to route_to('snippets#show', id: '1')
end
it 'to #show from unscoped routing' do
expect(get("/snippets/1")).to route_to('snippets#show', id: '1')
it 'to #raw from unscoped routing' do
expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1')
end
it_behaves_like 'redirecting a legacy path', '/snippets/1', '/-/snippets/1'
end
# help GET /help(.:format) help#index
......
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