Merge branch 'dz-scope-project-routes-3' into 'master'
Move some project routes under - scope See merge request gitlab-org/gitlab-ce!28830
This commit is contained in:
commit
d7b277df46
10 changed files with 83 additions and 54 deletions
|
@ -12,7 +12,7 @@ const Api = {
|
|||
groupProjectsPath: '/api/:version/groups/:id/projects.json',
|
||||
projectsPath: '/api/:version/projects.json',
|
||||
projectPath: '/api/:version/projects/:id',
|
||||
projectLabelsPath: '/:namespace_path/:project_path/labels',
|
||||
projectLabelsPath: '/:namespace_path/:project_path/-/labels',
|
||||
projectMergeRequestsPath: '/api/:version/projects/:id/merge_requests',
|
||||
projectMergeRequestPath: '/api/:version/projects/:id/merge_requests/:mrid',
|
||||
projectMergeRequestChangesPath: '/api/:version/projects/:id/merge_requests/:mrid/changes',
|
||||
|
|
|
@ -73,6 +73,7 @@ module Referable
|
|||
(?<url>
|
||||
#{Regexp.escape(Gitlab.config.gitlab.url)}
|
||||
\/#{Project.reference_pattern}
|
||||
(?:\/\-)?
|
||||
\/#{Regexp.escape(route)}
|
||||
\/#{pattern}
|
||||
(?<path>
|
||||
|
|
|
@ -124,6 +124,44 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
put :revoke
|
||||
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 of the /-/ scope.
|
||||
|
||||
|
@ -132,7 +170,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
#
|
||||
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
|
||||
member do
|
||||
get :branches
|
||||
|
@ -159,12 +196,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
end
|
||||
end
|
||||
|
||||
resources :services, constraints: { id: %r{[^/]+} }, only: [:edit, :update] do
|
||||
member do
|
||||
put :test
|
||||
end
|
||||
end
|
||||
|
||||
resource :mattermost, only: [:new, :create]
|
||||
|
||||
namespace :prometheus do
|
||||
|
@ -173,10 +204,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
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
|
||||
member do
|
||||
get :commit_change_content
|
||||
|
@ -372,31 +399,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
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 }
|
||||
|
||||
resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do
|
||||
member do
|
||||
post :toggle_subscription
|
||||
|
@ -408,14 +412,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
post :create_merge_request
|
||||
get :discussions, format: :json
|
||||
end
|
||||
|
||||
collection do
|
||||
post :bulk_update
|
||||
post :import_csv
|
||||
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
|
||||
member do
|
||||
delete :delete_attachment
|
||||
|
@ -426,8 +429,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
|
||||
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 :uploads, only: [:create] do
|
||||
|
@ -510,7 +511,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
|
|||
as: :project) do
|
||||
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
|
||||
: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
|
||||
|
|
|
@ -101,7 +101,7 @@ describe GitlabRoutingHelper do
|
|||
it 'returns project milestone edit path when given entity parent is not a Group' do
|
||||
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
|
||||
|
|
|
@ -264,7 +264,7 @@ describe('Api', () => {
|
|||
const namespace = 'some namespace';
|
||||
const project = 'some project';
|
||||
const labelData = { some: 'data' };
|
||||
const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/labels`;
|
||||
const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/-/labels`;
|
||||
const expectedData = {
|
||||
label: labelData,
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ export const BoardsMockData = {
|
|||
},
|
||||
],
|
||||
},
|
||||
'/test/issue-boards/milestones.json': [
|
||||
'/test/issue-boards/-/milestones.json': [
|
||||
{
|
||||
id: 1,
|
||||
title: 'test',
|
||||
|
@ -58,10 +58,10 @@ export const BoardsMockData = {
|
|||
'/test/-/boards/1/lists': listObj,
|
||||
},
|
||||
PUT: {
|
||||
'/test/issue-boards/board/1/lists{/id}': {},
|
||||
'/test/issue-boards/-/board/1/lists{/id}': {},
|
||||
},
|
||||
DELETE: {
|
||||
'/test/issue-boards/board/1/lists{/id}': {},
|
||||
'/test/issue-boards/-/board/1/lists{/id}': {},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -71,7 +71,7 @@ export const boardsMockInterceptor = config => {
|
|||
};
|
||||
|
||||
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 bulkUpdatePath = opts.bulkUpdatePath || '';
|
||||
const boardId = opts.boardId || '1';
|
||||
|
|
|
@ -32,7 +32,7 @@ describe Gitlab::UrlBuilder do
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -520,4 +520,20 @@ describe Milestone do
|
|||
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
|
||||
|
|
|
@ -1147,7 +1147,7 @@ describe Project do
|
|||
allow(project).to receive(:avatar_in_git) { true }
|
||||
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}" }
|
||||
end
|
||||
|
|
|
@ -470,18 +470,23 @@ describe 'project routing' do
|
|||
it_behaves_like 'RESTful project resources' do
|
||||
let(:controller) { 'milestones' }
|
||||
let(:actions) { [:index, :create, :new, :edit, :show, :update] }
|
||||
let(:controller_path) { '/-/milestones' }
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/milestones", "/gitlab/gitlabhq/-/milestones"
|
||||
end
|
||||
|
||||
# project_labels GET /:project_id/labels(.:format) labels#index
|
||||
describe Projects::LabelsController, 'routing' 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
|
||||
|
||||
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/labels", "/gitlab/gitlabhq/-/labels"
|
||||
end
|
||||
|
||||
# sort_project_issues POST /:project_id/issues/sort(.:format) issues#sort
|
||||
|
@ -623,20 +628,24 @@ describe 'project routing' do
|
|||
|
||||
describe Projects::ForksController, 'routing' 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
|
||||
|
||||
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
|
||||
|
||||
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/forks", "/gitlab/gitlabhq/-/forks"
|
||||
end
|
||||
|
||||
# project_avatar DELETE /project/avatar(.:format) projects/avatars#destroy
|
||||
describe Projects::AvatarsController, 'routing' 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')
|
||||
end
|
||||
|
||||
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/avatar", "/gitlab/gitlabhq/-/avatar"
|
||||
end
|
||||
|
||||
describe Projects::PagesDomainsController, 'routing' do
|
||||
|
|
Loading…
Reference in a new issue