Commit 82f259bc authored by charlie ablett's avatar charlie ablett

Merge branch 'dz-scope-some-global-routes' into 'master'

Move some global routes to - scope

See merge request gitlab-org/gitlab!27106
parents 6d0c0fa0 62149d37
---
title: Move some global routes to - scope
merge_request: 27106
author:
type: changed
......@@ -71,6 +71,8 @@ Rails.application.routes.draw do
# Health check
get 'health_check(/:checks)' => 'health_check#index', as: :health_check
# Begin of the /-/ scope.
# Use this scope for all new global routes.
scope path: '-' do
# '/-/health' implemented by BasicHealthCheck middleware
get 'liveness' => 'health#liveness'
......@@ -122,6 +124,10 @@ Rails.application.routes.draw do
draw :country_state
draw :subscription
draw :analytics
scope '/push_from_secondary/:geo_node_id' do
draw :git_http
end
end
if ENV['GITLAB_CHAOS_SECRET'] || Rails.env.development? || Rails.env.test?
......@@ -136,7 +142,24 @@ Rails.application.routes.draw do
# Notification settings
resources :notification_settings, only: [:create, :update]
resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
member do
post :accept
match :decline, via: [:get, :post]
end
end
resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
member do
get :unsubscribe
end
end
# Spam reports
resources :abuse_reports, only: [:new, :create]
end
# End of the /-/ scope.
concern :clusterable do
resources :clusters, only: [:index, :new, :show, :update, :destroy] do
......@@ -167,22 +190,24 @@ Rails.application.routes.draw do
end
end
# Invites
resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
member do
post :accept
match :decline, via: [:get, :post]
# Deprecated routes.
# Will be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/210024
scope as: :deprecated do
resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
member do
post :accept
match :decline, via: [:get, :post]
end
end
end
resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
member do
get :unsubscribe
resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
member do
get :unsubscribe
end
end
end
# Spam reports
resources :abuse_reports, only: [:new, :create]
resources :abuse_reports, only: [:new, :create]
end
resources :groups, only: [:index, :new, :create] do
post :preview_markdown
......@@ -192,12 +217,6 @@ Rails.application.routes.draw do
get '/projects/:id' => 'projects#resolve'
Gitlab.ee do
scope '/-/push_from_secondary/:geo_node_id' do
draw :git_http
end
end
draw :git_http
draw :api
draw :sidekiq
......
......@@ -313,3 +313,34 @@ describe HealthCheckController, 'routing' do
expect(get('/health_check/email')).to route_to('health_check#index', checks: 'email')
end
end
describe InvitesController, 'routing' do
let_it_be(:member) { create(:project_member, :invited) }
it 'to #show' do
expect(get("/-/invites/#{member.invite_token}")).to route_to('invites#show', id: member.invite_token)
end
it 'to legacy route' do
expect(get("/invites/#{member.invite_token}")).to route_to('invites#show', id: member.invite_token)
end
end
describe AbuseReportsController, 'routing' do
let_it_be(:user) { create(:user) }
it 'to #new' do
expect(get("/-/abuse_reports/new?user_id=#{user.id}")).to route_to('abuse_reports#new', user_id: user.id.to_s)
end
it 'to legacy route' do
expect(get("/abuse_reports/new?user_id=#{user.id}")).to route_to('abuse_reports#new', user_id: user.id.to_s)
end
end
describe SentNotificationsController, 'routing' do
it 'to #unsubscribe' do
expect(get("/-/sent_notifications/4bee17d4a63ed60cf5db53417e9aeb4c/unsubscribe"))
.to route_to('sent_notifications#unsubscribe', id: '4bee17d4a63ed60cf5db53417e9aeb4c')
end
end
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