diff options
-rw-r--r-- | app/assets/javascripts/api.js | 2 | ||||
-rw-r--r-- | app/models/concerns/referable.rb | 1 | ||||
-rw-r--r-- | config/routes/project.rb | 83 | ||||
-rw-r--r-- | spec/helpers/gitlab_routing_helper_spec.rb | 2 | ||||
-rw-r--r-- | spec/javascripts/api_spec.js | 2 | ||||
-rw-r--r-- | spec/javascripts/boards/mock_data.js | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/url_builder_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/milestone_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 2 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 19 |
10 files changed, 83 insertions, 54 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index e583a8affd4..7cebb88f3a4 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -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', diff --git a/app/models/concerns/referable.rb b/app/models/concerns/referable.rb index 58143a32fdc..4a506146de3 100644 --- a/app/models/concerns/referable.rb +++ b/app/models/concerns/referable.rb @@ -73,6 +73,7 @@ module Referable (?<url> #{Regexp.escape(Gitlab.config.gitlab.url)} \/#{Project.reference_pattern} + (?:\/\-)? \/#{Regexp.escape(route)} \/#{pattern} (?<path> diff --git a/config/routes/project.rb b/config/routes/project.rb index 1e94bdc245f..840dc4c7844 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -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 diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb index 143b28728a3..027480143bd 100644 --- a/spec/helpers/gitlab_routing_helper_spec.rb +++ b/spec/helpers/gitlab_routing_helper_spec.rb @@ -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 diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index 805bb10bda6..d9dcb08b177 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -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, }; diff --git a/spec/javascripts/boards/mock_data.js b/spec/javascripts/boards/mock_data.js index 93a0f29af0a..9854cf49e97 100644 --- a/spec/javascripts/boards/mock_data.js +++ b/spec/javascripts/boards/mock_data.js @@ -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'; diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index 9f495a5d50b..bbcb92608d8 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -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 diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 752a7965704..0fa4e470eef 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -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 diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 08662231fdf..453f9761602 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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 diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 6f40e88d26f..83775b1040e 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -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 |