Commit 74001467 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dz-scope-project-routes-2' into 'master'

Move more project routes under /-/ scope

See merge request gitlab-org/gitlab-ce!28717
parents 018360f1 e6442dde
...@@ -26,17 +26,106 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -26,17 +26,106 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
module: :projects, module: :projects,
as: :project) do as: :project) do
resources :autocomplete_sources, only: [] do # Begin of the /-/ scope.
collection do # Use this scope for all new project routes.
get 'members' scope '-' do
get 'issues' get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive'
get 'merge_requests'
get 'labels' resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
get 'milestones' collection do
get 'commands' resources :artifacts, only: [] do
get 'snippets' 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 end
# End of the /-/ scope.
# #
# Templates # Templates
...@@ -84,19 +173,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -84,19 +173,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
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 :releases, only: [:index]
resources :forks, only: [:index, :new, :create] resources :forks, only: [:index, :new, :create]
resource :import, only: [:new, :create, :show] resource :import, only: [:new, :create, :show]
...@@ -267,47 +343,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -267,47 +343,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :functions, only: [:index] resources :functions, only: [:index]
end 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 draw :legacy_builds
resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do
...@@ -379,21 +414,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -379,21 +414,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
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 :group_links, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ }
resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do
...@@ -443,25 +463,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -443,25 +463,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
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 resources :error_tracking, only: [:index], controller: :error_tracking do
collection do collection do
post :list_projects post :list_projects
...@@ -507,7 +508,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -507,7 +508,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
constraints: { project_id: Gitlab::PathRegex.project_route_regex }, constraints: { project_id: Gitlab::PathRegex.project_route_regex },
module: :projects, module: :projects,
as: :project) do 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 end
end end
...@@ -138,9 +138,11 @@ describe 'project routing' do ...@@ -138,9 +138,11 @@ describe 'project routing' do
describe Projects::AutocompleteSourcesController, 'routing' do describe Projects::AutocompleteSourcesController, 'routing' do
[:members, :issues, :merge_requests, :labels, :milestones, :commands, :snippets].each do |action| [:members, :issues, :merge_requests, :labels, :milestones, :commands, :snippets].each do |action|
it "to ##{action}" do 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
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/autocomplete_sources/labels", "/gitlab/gitlabhq/-/autocomplete_sources/labels"
end end
# pages_project_wikis GET /:project_id/wikis/pages(.:format) projects/wikis#pages # pages_project_wikis GET /:project_id/wikis/pages(.:format) projects/wikis#pages
...@@ -239,7 +241,10 @@ describe 'project routing' do ...@@ -239,7 +241,10 @@ describe 'project routing' do
it_behaves_like 'RESTful project resources' do it_behaves_like 'RESTful project resources' do
let(:actions) { [:index, :new, :create, :edit, :update] } let(:actions) { [:index, :new, :create, :edit, :update] }
let(:controller) { 'deploy_keys' } let(:controller) { 'deploy_keys' }
let(:controller_path) { '/-/deploy_keys' }
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/deploy_keys", "/gitlab/gitlabhq/-/deploy_keys"
end end
# project_protected_branches GET /:project_id/protected_branches(.:format) protected_branches#index # project_protected_branches GET /:project_id/protected_branches(.:format) protected_branches#index
...@@ -447,7 +452,10 @@ describe 'project routing' do ...@@ -447,7 +452,10 @@ describe 'project routing' do
it_behaves_like 'RESTful project resources' do it_behaves_like 'RESTful project resources' do
let(:actions) { [:index, :create, :update, :destroy] } let(:actions) { [:index, :create, :update, :destroy] }
let(:controller) { 'project_members' } let(:controller) { 'project_members' }
let(:controller_path) { '/-/project_members' }
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/project_members", "/gitlab/gitlabhq/-/project_members"
end end
# project_milestones GET /:project_id/milestones(.:format) milestones#index # project_milestones GET /:project_id/milestones(.:format) milestones#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