Commit d7b277df authored by Lin Jen-Shin's avatar Lin Jen-Shin

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

Move some project routes under - scope

See merge request gitlab-org/gitlab-ce!28830
parents 5cd0e721 bd4a3b6e
...@@ -12,7 +12,7 @@ const Api = { ...@@ -12,7 +12,7 @@ const Api = {
groupProjectsPath: '/api/:version/groups/:id/projects.json', groupProjectsPath: '/api/:version/groups/:id/projects.json',
projectsPath: '/api/:version/projects.json', projectsPath: '/api/:version/projects.json',
projectPath: '/api/:version/projects/:id', projectPath: '/api/:version/projects/:id',
projectLabelsPath: '/:namespace_path/:project_path/labels', projectLabelsPath: '/:namespace_path/:project_path/-/labels',
projectMergeRequestsPath: '/api/:version/projects/:id/merge_requests', projectMergeRequestsPath: '/api/:version/projects/:id/merge_requests',
projectMergeRequestPath: '/api/:version/projects/:id/merge_requests/:mrid', projectMergeRequestPath: '/api/:version/projects/:id/merge_requests/:mrid',
projectMergeRequestChangesPath: '/api/:version/projects/:id/merge_requests/:mrid/changes', projectMergeRequestChangesPath: '/api/:version/projects/:id/merge_requests/:mrid/changes',
......
...@@ -73,6 +73,7 @@ module Referable ...@@ -73,6 +73,7 @@ module Referable
(?<url> (?<url>
#{Regexp.escape(Gitlab.config.gitlab.url)} #{Regexp.escape(Gitlab.config.gitlab.url)}
\/#{Project.reference_pattern} \/#{Project.reference_pattern}
(?:\/\-)?
\/#{Regexp.escape(route)} \/#{Regexp.escape(route)}
\/#{pattern} \/#{pattern}
(?<path> (?<path>
......
...@@ -124,6 +124,44 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -124,6 +124,44 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
put :revoke put :revoke
end end
end end
resources :milestones, constraints: { id: /\d+/ } do
member do
post :promote
put :sort_issues
put :sort_merge_requests
get :merge_requests
get :participants
get :labels
end
end
resources :labels, except: [:show], constraints: { id: /\d+/ } do
collection do
post :generate
post :set_priorities
end
member do
post :promote
post :toggle_subscription
delete :remove_priority
end
end
resources :services, constraints: { id: %r{[^/]+} }, only: [:edit, :update] do
member do
put :test
end
end
resources :boards, only: [:index, :show], constraints: { id: /\d+/ }
resources :releases, only: [:index]
resources :forks, only: [:index, :new, :create]
resources :group_links, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ }
resource :import, only: [:new, :create, :show]
resource :avatar, only: [:show, :destroy]
end end
# End of the /-/ scope. # End of the /-/ scope.
...@@ -132,7 +170,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -132,7 +170,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# #
get '/templates/:template_type/:key' => 'templates#show', as: :template, constraints: { key: %r{[^/]+} } get '/templates/:template_type/:key' => 'templates#show', as: :template, constraints: { key: %r{[^/]+} }
resource :avatar, only: [:show, :destroy]
resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
member do member do
get :branches get :branches
...@@ -159,12 +196,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -159,12 +196,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :services, constraints: { id: %r{[^/]+} }, only: [:edit, :update] do
member do
put :test
end
end
resource :mattermost, only: [:new, :create] resource :mattermost, only: [:new, :create]
namespace :prometheus do namespace :prometheus do
...@@ -173,10 +204,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -173,10 +204,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :releases, only: [:index]
resources :forks, only: [:index, :new, :create]
resource :import, only: [:new, :create, :show]
resources :merge_requests, concerns: :awardable, except: [:new, :create], constraints: { id: /\d+/ } do resources :merge_requests, concerns: :awardable, except: [:new, :create], constraints: { id: /\d+/ } do
member do member do
get :commit_change_content get :commit_change_content
...@@ -372,31 +399,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -372,31 +399,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
end end
resources :milestones, constraints: { id: /\d+/ } do
member do
post :promote
put :sort_issues
put :sort_merge_requests
get :merge_requests
get :participants
get :labels
end
end
resources :labels, except: [:show], constraints: { id: /\d+/ } do
collection do
post :generate
post :set_priorities
end
member do
post :promote
post :toggle_subscription
delete :remove_priority
end
end
get :issues, to: 'issues#calendar', constraints: lambda { |req| req.format == :ics } get :issues, to: 'issues#calendar', constraints: lambda { |req| req.format == :ics }
resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do
member do member do
post :toggle_subscription post :toggle_subscription
...@@ -408,14 +412,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -408,14 +412,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :create_merge_request post :create_merge_request
get :discussions, format: :json get :discussions, format: :json
end end
collection do collection do
post :bulk_update post :bulk_update
post :import_csv post :import_csv
end end
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 resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do
member do member do
delete :delete_attachment delete :delete_attachment
...@@ -426,8 +429,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -426,8 +429,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get 'noteable/:target_type/:target_id/notes' => 'notes#index', as: 'noteable_notes' get 'noteable/:target_type/:target_id/notes' => 'notes#index', as: 'noteable_notes'
resources :boards, only: [:index, :show], constraints: { id: /\d+/ }
resources :todos, only: [:create] resources :todos, only: [:create]
resources :uploads, only: [:create] do resources :uploads, only: [:create] do
...@@ -510,7 +511,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -510,7 +511,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
as: :project) do as: :project) do
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags, Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources, :network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens) :project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar)
end end
end end
end end
...@@ -101,7 +101,7 @@ describe GitlabRoutingHelper do ...@@ -101,7 +101,7 @@ describe GitlabRoutingHelper do
it 'returns project milestone edit path when given entity parent is not a Group' do it 'returns project milestone edit path when given entity parent is not a Group' do
milestone = create(:milestone, group: nil) milestone = create(:milestone, group: nil)
expect(edit_milestone_path(milestone)).to eq("/#{milestone.project.full_path}/milestones/#{milestone.iid}/edit") expect(edit_milestone_path(milestone)).to eq("/#{milestone.project.full_path}/-/milestones/#{milestone.iid}/edit")
end end
end end
end end
...@@ -264,7 +264,7 @@ describe('Api', () => { ...@@ -264,7 +264,7 @@ describe('Api', () => {
const namespace = 'some namespace'; const namespace = 'some namespace';
const project = 'some project'; const project = 'some project';
const labelData = { some: 'data' }; const labelData = { some: 'data' };
const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/labels`; const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/-/labels`;
const expectedData = { const expectedData = {
label: labelData, label: labelData,
}; };
......
...@@ -47,7 +47,7 @@ export const BoardsMockData = { ...@@ -47,7 +47,7 @@ export const BoardsMockData = {
}, },
], ],
}, },
'/test/issue-boards/milestones.json': [ '/test/issue-boards/-/milestones.json': [
{ {
id: 1, id: 1,
title: 'test', title: 'test',
...@@ -58,10 +58,10 @@ export const BoardsMockData = { ...@@ -58,10 +58,10 @@ export const BoardsMockData = {
'/test/-/boards/1/lists': listObj, '/test/-/boards/1/lists': listObj,
}, },
PUT: { PUT: {
'/test/issue-boards/board/1/lists{/id}': {}, '/test/issue-boards/-/board/1/lists{/id}': {},
}, },
DELETE: { DELETE: {
'/test/issue-boards/board/1/lists{/id}': {}, '/test/issue-boards/-/board/1/lists{/id}': {},
}, },
}; };
...@@ -71,7 +71,7 @@ export const boardsMockInterceptor = config => { ...@@ -71,7 +71,7 @@ export const boardsMockInterceptor = config => {
}; };
export const mockBoardService = (opts = {}) => { export const mockBoardService = (opts = {}) => {
const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/boards.json'; const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/-/boards.json';
const listsEndpoint = opts.listsEndpoint || '/test/-/boards/1/lists'; const listsEndpoint = opts.listsEndpoint || '/test/-/boards/1/lists';
const bulkUpdatePath = opts.bulkUpdatePath || ''; const bulkUpdatePath = opts.bulkUpdatePath || '';
const boardId = opts.boardId || '1'; const boardId = opts.boardId || '1';
......
...@@ -32,7 +32,7 @@ describe Gitlab::UrlBuilder do ...@@ -32,7 +32,7 @@ describe Gitlab::UrlBuilder do
url = described_class.build(milestone) url = described_class.build(milestone)
expect(url).to eq "#{Settings.gitlab['url']}/#{milestone.project.full_path}/milestones/#{milestone.iid}" expect(url).to eq "#{Settings.gitlab['url']}/#{milestone.project.full_path}/-/milestones/#{milestone.iid}"
end end
end end
......
...@@ -520,4 +520,20 @@ describe Milestone do ...@@ -520,4 +520,20 @@ describe Milestone do
end end
end end
end end
describe '.reference_pattern' do
subject { described_class.reference_pattern }
it { is_expected.to match('gitlab-org/gitlab-ce%123') }
it { is_expected.to match('gitlab-org/gitlab-ce%"my-milestone"') }
end
describe '.link_reference_pattern' do
subject { described_class.link_reference_pattern }
it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-ce/milestones/123") }
it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-ce/-/milestones/123") }
it { is_expected.not_to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-ce/issues/123") }
it { is_expected.not_to match("gitlab-org/gitlab-ce/milestones/123") }
end
end end
...@@ -1147,7 +1147,7 @@ describe Project do ...@@ -1147,7 +1147,7 @@ describe Project do
allow(project).to receive(:avatar_in_git) { true } allow(project).to receive(:avatar_in_git) { true }
end end
let(:avatar_path) { "/#{project.full_path}/avatar" } let(:avatar_path) { "/#{project.full_path}/-/avatar" }
it { is_expected.to eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } it { is_expected.to eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
end end
......
...@@ -470,18 +470,23 @@ describe 'project routing' do ...@@ -470,18 +470,23 @@ describe 'project routing' do
it_behaves_like 'RESTful project resources' do it_behaves_like 'RESTful project resources' do
let(:controller) { 'milestones' } let(:controller) { 'milestones' }
let(:actions) { [:index, :create, :new, :edit, :show, :update] } let(:actions) { [:index, :create, :new, :edit, :show, :update] }
let(:controller_path) { '/-/milestones' }
end end
it 'to #promote' do it 'to #promote' do
expect(post('/gitlab/gitlabhq/milestones/1/promote')).to route_to('projects/milestones#promote', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "1") expect(post('/gitlab/gitlabhq/-/milestones/1/promote')).to route_to('projects/milestones#promote', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "1")
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/milestones", "/gitlab/gitlabhq/-/milestones"
end end
# project_labels GET /:project_id/labels(.:format) labels#index # project_labels GET /:project_id/labels(.:format) labels#index
describe Projects::LabelsController, 'routing' do describe Projects::LabelsController, 'routing' do
it 'to #index' do it 'to #index' do
expect(get('/gitlab/gitlabhq/labels')).to route_to('projects/labels#index', namespace_id: 'gitlab', project_id: 'gitlabhq') expect(get('/gitlab/gitlabhq/-/labels')).to route_to('projects/labels#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/labels", "/gitlab/gitlabhq/-/labels"
end end
# sort_project_issues POST /:project_id/issues/sort(.:format) issues#sort # sort_project_issues POST /:project_id/issues/sort(.:format) issues#sort
...@@ -623,20 +628,24 @@ describe 'project routing' do ...@@ -623,20 +628,24 @@ describe 'project routing' do
describe Projects::ForksController, 'routing' do describe Projects::ForksController, 'routing' do
it 'to #new' do it 'to #new' do
expect(get('/gitlab/gitlabhq/forks/new')).to route_to('projects/forks#new', namespace_id: 'gitlab', project_id: 'gitlabhq') expect(get('/gitlab/gitlabhq/-/forks/new')).to route_to('projects/forks#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
end end
it 'to #create' do it 'to #create' do
expect(post('/gitlab/gitlabhq/forks')).to route_to('projects/forks#create', namespace_id: 'gitlab', project_id: 'gitlabhq') expect(post('/gitlab/gitlabhq/-/forks')).to route_to('projects/forks#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/forks", "/gitlab/gitlabhq/-/forks"
end end
# project_avatar DELETE /project/avatar(.:format) projects/avatars#destroy # project_avatar DELETE /project/avatar(.:format) projects/avatars#destroy
describe Projects::AvatarsController, 'routing' do describe Projects::AvatarsController, 'routing' do
it 'to #destroy' do it 'to #destroy' do
expect(delete('/gitlab/gitlabhq/avatar')).to route_to( expect(delete('/gitlab/gitlabhq/-/avatar')).to route_to(
'projects/avatars#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq') 'projects/avatars#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq')
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/avatar", "/gitlab/gitlabhq/-/avatar"
end end
describe Projects::PagesDomainsController, 'routing' do describe Projects::PagesDomainsController, 'routing' do
......
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