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
8fb9ea95
Commit
8fb9ea95
authored
Dec 19, 2019
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy merge request routes to - scope
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
f588407e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
103 deletions
+137
-103
changelogs/unreleased/dz-move-mr-routes-2.yml
changelogs/unreleased/dz-move-mr-routes-2.yml
+5
-0
config/routes/merge_requests.rb
config/routes/merge_requests.rb
+76
-0
config/routes/project.rb
config/routes/project.rb
+9
-74
ee/config/routes/merge_requests_ee.rb
ee/config/routes/merge_requests_ee.rb
+32
-0
ee/config/routes/project.rb
ee/config/routes/project.rb
+9
-29
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+6
-0
No files found.
changelogs/unreleased/dz-move-mr-routes-2.yml
0 → 100644
View file @
8fb9ea95
---
title
:
Copy merge request routes to the - scope
merge_request
:
22082
author
:
type
:
changed
config/routes/merge_requests.rb
0 → 100644
View file @
8fb9ea95
# frozen_string_literal: true
resources
:merge_requests
,
concerns: :awardable
,
except:
[
:new
,
:create
,
:show
],
constraints:
{
id:
/\d+/
}
do
member
do
get
:show
# Insert this first to ensure redirections using merge_requests#show match this route
get
:commit_change_content
post
:merge
post
:cancel_auto_merge
get
:pipeline_status
get
:ci_environments_status
post
:toggle_subscription
post
:remove_wip
post
:assign_related_issues
get
:discussions
,
format: :json
post
:rebase
get
:test_reports
get
:exposed_artifacts
scope
constraints:
->
(
req
)
{
req
.
format
==
:json
},
as: :json
do
get
:commits
get
:pipelines
get
:diffs
,
to:
'merge_requests/diffs#show'
get
:diffs_batch
,
to:
'merge_requests/diffs#diffs_batch'
get
:diffs_metadata
,
to:
'merge_requests/diffs#diffs_metadata'
get
:widget
,
to:
'merge_requests/content#widget'
get
:cached_widget
,
to:
'merge_requests/content#cached_widget'
end
scope
action: :show
do
get
:commits
,
defaults:
{
tab:
'commits'
}
get
:pipelines
,
defaults:
{
tab:
'pipelines'
}
get
:diffs
,
defaults:
{
tab:
'diffs'
}
end
get
:diff_for_path
,
controller:
'merge_requests/diffs'
scope
controller:
'merge_requests/conflicts'
do
get
:conflicts
,
action: :show
get
:conflict_for_path
post
:resolve_conflicts
end
end
collection
do
get
:diff_for_path
post
:bulk_update
end
resources
:discussions
,
only:
[
:show
],
constraints:
{
id:
/\h{40}/
}
do
member
do
post
:resolve
delete
:resolve
,
action: :unresolve
end
end
end
scope
path:
'merge_requests'
,
controller:
'merge_requests/creations'
do
post
''
,
action: :create
,
as:
nil
scope
path:
'new'
,
as: :new_merge_request
do
get
''
,
action: :new
scope
constraints:
->
(
req
)
{
req
.
format
==
:json
},
as: :json
do
get
:diffs
get
:pipelines
end
scope
action: :new
do
get
:diffs
,
defaults:
{
tab:
'diffs'
}
get
:pipelines
,
defaults:
{
tab:
'pipelines'
}
end
get
:diff_for_path
get
:branch_from
get
:branch_to
end
end
config/routes/project.rb
View file @
8fb9ea95
...
@@ -328,80 +328,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
...
@@ -328,80 +328,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
end
end
resources
:merge_requests
,
concerns: :awardable
,
except:
[
:new
,
:create
,
:show
],
constraints:
{
id:
/\d+/
}
do
# Unscoped route. It will be replaced with redirect to /-/merge_requests/
member
do
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
get
:show
# Insert this first to ensure redirections using merge_requests#show match this route
draw
:merge_requests
get
:commit_change_content
post
:merge
# To ensure an old unscoped routing is used for the UI we need to
post
:cancel_auto_merge
# add prefix 'as' to the scope routing and place it below original MR routing.
get
:pipeline_status
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
get
:ci_environments_status
scope
'-'
,
as:
'scoped'
do
post
:toggle_subscription
draw
:merge_requests
post
:remove_wip
post
:assign_related_issues
get
:discussions
,
format: :json
post
:rebase
get
:test_reports
get
:exposed_artifacts
scope
constraints:
->
(
req
)
{
req
.
format
==
:json
},
as: :json
do
get
:commits
get
:pipelines
get
:diffs
,
to:
'merge_requests/diffs#show'
get
:diffs_batch
,
to:
'merge_requests/diffs#diffs_batch'
get
:diffs_metadata
,
to:
'merge_requests/diffs#diffs_metadata'
get
:widget
,
to:
'merge_requests/content#widget'
get
:cached_widget
,
to:
'merge_requests/content#cached_widget'
end
scope
action: :show
do
get
:commits
,
defaults:
{
tab:
'commits'
}
get
:pipelines
,
defaults:
{
tab:
'pipelines'
}
get
:diffs
,
defaults:
{
tab:
'diffs'
}
end
get
:diff_for_path
,
controller:
'merge_requests/diffs'
scope
controller:
'merge_requests/conflicts'
do
get
:conflicts
,
action: :show
get
:conflict_for_path
post
:resolve_conflicts
end
end
collection
do
get
:diff_for_path
post
:bulk_update
end
resources
:discussions
,
only:
[
:show
],
constraints:
{
id:
/\h{40}/
}
do
member
do
post
:resolve
delete
:resolve
,
action: :unresolve
end
end
end
scope
path:
'merge_requests'
,
controller:
'merge_requests/creations'
do
post
''
,
action: :create
,
as:
nil
scope
path:
'new'
,
as: :new_merge_request
do
get
''
,
action: :new
scope
constraints:
->
(
req
)
{
req
.
format
==
:json
},
as: :json
do
get
:diffs
get
:pipelines
end
scope
action: :new
do
get
:diffs
,
defaults:
{
tab:
'diffs'
}
get
:pipelines
,
defaults:
{
tab:
'pipelines'
}
end
get
:diff_for_path
get
:branch_from
get
:branch_to
end
end
end
resources
:pipelines
,
only:
[
:index
,
:new
,
:create
,
:show
]
do
resources
:pipelines
,
only:
[
:index
,
:new
,
:create
,
:show
]
do
...
...
ee/config/routes/merge_requests_ee.rb
0 → 100644
View file @
8fb9ea95
# frozen_string_literal: true
resources
:merge_requests
,
only:
[],
constraints:
{
id:
/\d+/
}
do
member
do
get
'/descriptions/:version_id/diff'
,
action: :description_diff
,
as: :description_diff
get
:metrics_reports
get
:license_management_reports
get
:container_scanning_reports
get
:dependency_scanning_reports
get
:sast_reports
get
:dast_reports
get
:approvals
post
:approvals
,
action: :approve
delete
:approvals
,
action: :unapprove
post
:rebase
end
resources
:approvers
,
only: :destroy
delete
'approvers'
,
to:
'approvers#destroy_via_user_id'
,
as: :approver_via_user_id
resources
:approver_groups
,
only: :destroy
scope
module: :merge_requests
do
resources
:drafts
,
only:
[
:index
,
:update
,
:create
,
:destroy
]
do
collection
do
post
:publish
delete
:discard
end
end
end
end
ee/config/routes/project.rb
View file @
8fb9ea95
...
@@ -137,35 +137,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
...
@@ -137,35 +137,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get
'/service_desk'
=>
'service_desk#show'
,
as: :service_desk
get
'/service_desk'
=>
'service_desk#show'
,
as: :service_desk
put
'/service_desk'
=>
'service_desk#update'
,
as: :service_desk_refresh
put
'/service_desk'
=>
'service_desk#update'
,
as: :service_desk_refresh
resources
:merge_requests
,
only:
[],
constraints:
{
id:
/\d+/
}
do
# Unscoped route. It will be replaced with redirect to /-/merge_requests/
member
do
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
get
'/descriptions/:version_id/diff'
,
action: :description_diff
,
as: :description_diff
draw
:merge_requests_ee
get
:metrics_reports
get
:license_management_reports
# To ensure an old unscoped routing is used for the UI we need to
get
:container_scanning_reports
# add prefix 'as' to the scope routing and place it below original MR routing.
get
:dependency_scanning_reports
# Issue https://gitlab.com/gitlab-org/gitlab/issues/118849
get
:sast_reports
scope
'-'
,
as:
'scoped'
do
get
:dast_reports
draw
:merge_requests_ee
get
:approvals
post
:approvals
,
action: :approve
delete
:approvals
,
action: :unapprove
post
:rebase
end
resources
:approvers
,
only: :destroy
delete
'approvers'
,
to:
'approvers#destroy_via_user_id'
,
as: :approver_via_user_id
resources
:approver_groups
,
only: :destroy
scope
module: :merge_requests
do
resources
:drafts
,
only:
[
:index
,
:update
,
:create
,
:destroy
]
do
collection
do
post
:publish
delete
:discard
end
end
end
end
end
post
'/restore'
=>
'/projects#restore'
,
as: :restore
post
'/restore'
=>
'/projects#restore'
,
as: :restore
...
...
spec/routing/project_routing_spec.rb
View file @
8fb9ea95
...
@@ -314,6 +314,12 @@ describe 'project routing' do
...
@@ -314,6 +314,12 @@ describe 'project routing' do
expect
(
get
(
'/gitlab/gitlabhq/merge_requests/1/pipelines'
)).
to
route_to
(
'projects/merge_requests#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'1'
,
tab:
'pipelines'
)
expect
(
get
(
'/gitlab/gitlabhq/merge_requests/1/pipelines'
)).
to
route_to
(
'projects/merge_requests#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'1'
,
tab:
'pipelines'
)
end
end
it
'to #show from scoped route'
do
expect
(
get
(
'/gitlab/gitlabhq/-/merge_requests/1.diff'
)).
to
route_to
(
'projects/merge_requests#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'1'
,
format:
'diff'
)
expect
(
get
(
'/gitlab/gitlabhq/-/merge_requests/1.patch'
)).
to
route_to
(
'projects/merge_requests#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'1'
,
format:
'patch'
)
expect
(
get
(
'/gitlab/gitlabhq/-/merge_requests/1/diffs'
)).
to
route_to
(
'projects/merge_requests#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'1'
,
tab:
'diffs'
)
end
it_behaves_like
'RESTful project resources'
do
it_behaves_like
'RESTful project resources'
do
let
(
:controller
)
{
'merge_requests'
}
let
(
:controller
)
{
'merge_requests'
}
let
(
:actions
)
{
[
:index
,
:edit
,
:show
,
:update
]
}
let
(
:actions
)
{
[
:index
,
:edit
,
:show
,
:update
]
}
...
...
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