diff options
-rw-r--r-- | config/routes/project.rb | 199 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 10 |
2 files changed, 110 insertions, 99 deletions
diff --git a/config/routes/project.rb b/config/routes/project.rb index fdc2a3c0086..1e94bdc245f 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -26,17 +26,106 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do module: :projects, as: :project) do - resources :autocomplete_sources, only: [] do - collection do - get 'members' - get 'issues' - get 'merge_requests' - get 'labels' - get 'milestones' - get 'commands' - get 'snippets' + # Begin of the /-/ scope. + # Use this scope for all new project routes. + scope '-' do + get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive' + + resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do + collection do + resources :artifacts, only: [] do + collection do + get :latest_succeeded, + path: '*ref_name_and_path', + format: false + end + end + end + + member do + get :status + post :cancel + post :unschedule + post :retry + post :play + post :erase + get :trace, defaults: { format: 'json' } + get :raw + get :terminal + get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', constraints: { format: nil } + end + + resource :artifacts, only: [] do + get :download + get :browse, path: 'browse(/*path)', format: false + get :file, path: 'file/*path', format: false + get :raw, path: 'raw/*path', format: false + post :keep + end + end + + namespace :ci do + resource :lint, only: [:show, :create] + end + + namespace :settings do + get :members, to: redirect("%{namespace_id}/%{project_id}/project_members") + + resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do + post :reset_cache + put :reset_registration_token + end + + resource :operations, only: [:show, :update] + resource :integrations, only: [:show] + + resource :repository, only: [:show], controller: :repository do + post :create_deploy_token, path: 'deploy_token/create' + post :cleanup + end + end + + resources :autocomplete_sources, only: [] do + collection do + get 'members' + get 'issues' + get 'merge_requests' + get 'labels' + get 'milestones' + get 'commands' + get 'snippets' + end + end + + resources :project_members, except: [:show, :new, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+]+} }, concerns: :access_requestable do + collection do + delete :leave + + # Used for import team + # from another project + get :import + post :apply_import + end + + member do + post :resend_invite + end + end + + resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create, :edit, :update] do + member do + put :enable + put :disable + end + end + + resources :deploy_tokens, constraints: { id: /\d+/ }, only: [] do + member do + put :revoke + end end end + # End of the /-/ scope. # # Templates @@ -84,19 +173,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create, :edit, :update] do - member do - put :enable - put :disable - end - end - - resources :deploy_tokens, constraints: { id: /\d+/ }, only: [] do - member do - put :revoke - end - end - resources :releases, only: [:index] resources :forks, only: [:index, :new, :create] resource :import, only: [:new, :create, :show] @@ -267,47 +343,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resources :functions, only: [:index] end - scope '-' do - get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive' - - resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do - collection do - resources :artifacts, only: [] do - collection do - get :latest_succeeded, - path: '*ref_name_and_path', - format: false - end - end - end - - member do - get :status - post :cancel - post :unschedule - post :retry - post :play - post :erase - get :trace, defaults: { format: 'json' } - get :raw - get :terminal - get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', constraints: { format: nil } - end - - resource :artifacts, only: [] do - get :download - get :browse, path: 'browse(/*path)', format: false - get :file, path: 'file/*path', format: false - get :raw, path: 'raw/*path', format: false - post :keep - end - end - - namespace :ci do - resource :lint, only: [:show, :create] - end - end - draw :legacy_builds resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do @@ -379,21 +414,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :project_members, except: [:show, :new, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+]+} }, concerns: :access_requestable do - collection do - delete :leave - - # Used for import team - # from another project - get :import - post :apply_import - end - - member do - post :resend_invite - end - end - resources :group_links, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ } resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do @@ -443,25 +463,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - scope '-' do - namespace :settings do - get :members, to: redirect("%{namespace_id}/%{project_id}/project_members") - - resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do - post :reset_cache - put :reset_registration_token - end - - resource :operations, only: [:show, :update] - resource :integrations, only: [:show] - - resource :repository, only: [:show], controller: :repository do - post :create_deploy_token, path: 'deploy_token/create' - post :cleanup - end - end - end - resources :error_tracking, only: [:index], controller: :error_tracking do collection do post :list_projects @@ -507,7 +508,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do constraints: { project_id: Gitlab::PathRegex.project_route_regex }, module: :projects, as: :project) do - Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags, :network, :graphs) + Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags, + :network, :graphs, :autocomplete_sources, + :project_members, :deploy_keys, :deploy_tokens) end end end diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index dd9540c11d1..6f40e88d26f 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -138,9 +138,11 @@ describe 'project routing' do describe Projects::AutocompleteSourcesController, 'routing' do [:members, :issues, :merge_requests, :labels, :milestones, :commands, :snippets].each do |action| it "to ##{action}" do - expect(get("/gitlab/gitlabhq/autocomplete_sources/#{action}")).to route_to("projects/autocomplete_sources##{action}", namespace_id: 'gitlab', project_id: 'gitlabhq') + expect(get("/gitlab/gitlabhq/-/autocomplete_sources/#{action}")).to route_to("projects/autocomplete_sources##{action}", namespace_id: 'gitlab', project_id: 'gitlabhq') end end + + it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/autocomplete_sources/labels", "/gitlab/gitlabhq/-/autocomplete_sources/labels" end # pages_project_wikis GET /:project_id/wikis/pages(.:format) projects/wikis#pages @@ -239,7 +241,10 @@ describe 'project routing' do it_behaves_like 'RESTful project resources' do let(:actions) { [:index, :new, :create, :edit, :update] } let(:controller) { 'deploy_keys' } + let(:controller_path) { '/-/deploy_keys' } end + + it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/deploy_keys", "/gitlab/gitlabhq/-/deploy_keys" end # project_protected_branches GET /:project_id/protected_branches(.:format) protected_branches#index @@ -447,7 +452,10 @@ describe 'project routing' do it_behaves_like 'RESTful project resources' do let(:actions) { [:index, :create, :update, :destroy] } let(:controller) { 'project_members' } + let(:controller_path) { '/-/project_members' } end + + it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/project_members", "/gitlab/gitlabhq/-/project_members" end # project_milestones GET /:project_id/milestones(.:format) milestones#index |