Commit 7b1e9812 authored by Markus Koller's avatar Markus Koller

Move project hooks routes under /-/ scope

parent f0f0f6b3
---
title: Move project hooks routes under /-/ scope
merge_request: 57734
author:
type: performance
......@@ -397,6 +397,18 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
to: 'web_ide_schemas#show',
format: false,
as: :schema
resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do
member do
post :test
end
resources :hook_logs, only: [:show] do
member do
post :retry
end
end
end
end
# End of the /-/ scope.
......@@ -460,18 +472,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
draw :legacy_builds
resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do # rubocop: disable Cop/PutProjectRoutesUnderScope
member do
post :test # rubocop:todo Cop/PutProjectRoutesUnderScope
end
resources :hook_logs, only: [:show] do # rubocop: disable Cop/PutProjectRoutesUnderScope
member do
post :retry # rubocop:todo Cop/PutProjectRoutesUnderScope
end
end
end
resources :container_registry, only: [:index, :destroy, :show], # rubocop: disable Cop/PutProjectRoutesUnderScope
controller: 'registry/repositories'
......@@ -571,7 +571,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# Legacy routes.
# Introduced in 12.0.
# Should be removed with https://gitlab.com/gitlab-org/gitlab/issues/28848.
Gitlab::Routing.redirect_legacy_paths(self, :mirror, :tags,
Gitlab::Routing.redirect_legacy_paths(self, :mirror, :tags, :hooks,
:cycle_analytics, :mattermost, :variables, :triggers,
:environments, :protected_environments, :error_tracking, :alert_management,
:tracing,
......
......@@ -11,7 +11,7 @@ RSpec.describe ProjectHookPresenter do
subject { web_hook.present.logs_details_path(web_hook_log) }
let(:expected_path) do
"/#{project.namespace.path}/#{project.name}/hooks/#{web_hook.id}/hook_logs/#{web_hook_log.id}"
"/#{project.namespace.path}/#{project.name}/-/hooks/#{web_hook.id}/hook_logs/#{web_hook_log.id}"
end
it { is_expected.to eq(expected_path) }
......@@ -21,7 +21,7 @@ RSpec.describe ProjectHookPresenter do
subject { web_hook.present.logs_details_path(web_hook_log) }
let(:expected_path) do
"/#{project.namespace.path}/#{project.name}/hooks/#{web_hook.id}/hook_logs/#{web_hook_log.id}"
"/#{project.namespace.path}/#{project.name}/-/hooks/#{web_hook.id}/hook_logs/#{web_hook_log.id}"
end
it { is_expected.to eq(expected_path) }
......
......@@ -335,33 +335,37 @@ RSpec.describe 'project routing' do
end
end
# test_project_hook POST /:project_id/hooks/:id/test(.:format) hooks#test
# project_hooks GET /:project_id/hooks(.:format) hooks#index
# POST /:project_id/hooks(.:format) hooks#create
# edit_project_hook GET /:project_id/hooks/:id/edit(.:format) hooks#edit
# project_hook PUT /:project_id/hooks/:id(.:format) hooks#update
# DELETE /:project_id/hooks/:id(.:format) hooks#destroy
# test_project_hook POST /:project_id/-/hooks/:id/test(.:format) hooks#test
# project_hooks GET /:project_id/-/hooks(.:format) hooks#index
# POST /:project_id/-/hooks(.:format) hooks#create
# edit_project_hook GET /:project_id/-/hooks/:id/edit(.:format) hooks#edit
# project_hook PUT /:project_id/-/hooks/:id(.:format) hooks#update
# DELETE /:project_id/-/hooks/:id(.:format) hooks#destroy
describe Projects::HooksController, 'routing' do
it 'to #test' do
expect(post('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
expect(post('/gitlab/gitlabhq/-/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
end
it_behaves_like 'resource routing' do
let(:actions) { %i[index create destroy edit update] }
let(:base_path) { '/gitlab/gitlabhq/hooks' }
let(:base_path) { '/gitlab/gitlabhq/-/hooks' }
end
it_behaves_like 'redirecting a legacy path', '/gitlab/gitlabhq/hooks', '/gitlab/gitlabhq/-/hooks'
end
# retry_namespace_project_hook_hook_log POST /:project_id/hooks/:hook_id/hook_logs/:id/retry(.:format) projects/hook_logs#retry
# namespace_project_hook_hook_log GET /:project_id/hooks/:hook_id/hook_logs/:id(.:format) projects/hook_logs#show
# retry_namespace_project_hook_hook_log POST /:project_id/-/hooks/:hook_id/hook_logs/:id/retry(.:format) projects/hook_logs#retry
# namespace_project_hook_hook_log GET /:project_id/-/hooks/:hook_id/hook_logs/:id(.:format) projects/hook_logs#show
describe Projects::HookLogsController, 'routing' do
it 'to #retry' do
expect(post('/gitlab/gitlabhq/hooks/1/hook_logs/1/retry')).to route_to('projects/hook_logs#retry', namespace_id: 'gitlab', project_id: 'gitlabhq', hook_id: '1', id: '1')
expect(post('/gitlab/gitlabhq/-/hooks/1/hook_logs/1/retry')).to route_to('projects/hook_logs#retry', namespace_id: 'gitlab', project_id: 'gitlabhq', hook_id: '1', id: '1')
end
it 'to #show' do
expect(get('/gitlab/gitlabhq/hooks/1/hook_logs/1')).to route_to('projects/hook_logs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', hook_id: '1', id: '1')
expect(get('/gitlab/gitlabhq/-/hooks/1/hook_logs/1')).to route_to('projects/hook_logs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', hook_id: '1', id: '1')
end
it_behaves_like 'redirecting a legacy path', '/gitlab/gitlabhq/hooks/hook_logs/1', '/gitlab/gitlabhq/-/hooks/hook_logs/1'
end
# project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /\h{7,40}/, project_id: /[^\/]+/}
......
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