Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7b1e9812
Commit
7b1e9812
authored
Mar 29, 2021
by
Markus Koller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move project hooks routes under /-/ scope
parent
f0f0f6b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
27 deletions
+36
-27
changelogs/unreleased/29572-move-project-hooks-routes.yml
changelogs/unreleased/29572-move-project-hooks-routes.yml
+5
-0
config/routes/project.rb
config/routes/project.rb
+13
-13
spec/presenters/project_hook_presenter_spec.rb
spec/presenters/project_hook_presenter_spec.rb
+2
-2
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+16
-12
No files found.
changelogs/unreleased/29572-move-project-hooks-routes.yml
0 → 100644
View file @
7b1e9812
---
title
:
Move project hooks routes under /-/ scope
merge_request
:
57734
author
:
type
:
performance
config/routes/project.rb
View file @
7b1e9812
...
...
@@ -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
,
...
...
spec/presenters/project_hook_presenter_spec.rb
View file @
7b1e9812
...
...
@@ -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
)
}
...
...
spec/routing/project_routing_spec.rb
View file @
7b1e9812
...
...
@@ -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: /[^\/]+/}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment