diff --git a/config/routes.rb b/config/routes.rb index 3b0370551b9a61c61cd0a10cbabbd32bcce891e1..badff3199f49ae9e2ed430bd34007675a19cedf1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -311,9 +311,13 @@ # 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 diff --git a/config/routes/project.rb b/config/routes/project.rb index d62e2f1b2f2d390121455625895b2fc2c98671a4..f76f22fe3d32ef27b2143dd42a482c700124461f 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -568,13 +568,13 @@ # 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 @@ :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 diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index cd89674af0f717fd84e98f526a30ef79c1365309..fbcb68550c1646aba6b8da5da2cb28759574f844 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -113,7 +113,7 @@ def failure_message(constant_name, migration_helper, missing_words: [], addition 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 diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 056f4d30ea5eee361544e310d8973cd5d173c7a3..2b742c10b811a03a5ca059eb30d952ad76f1585e 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -310,9 +310,11 @@ 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 diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 7b9ba7838851c32f37e6ee7b5d85a51bc81ce35c..3bb8e22a63b5efa94372dc57862fdea9e124df92 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -96,9 +96,11 @@ 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