Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5dde0536
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5dde0536
编写于
10月 26, 2017
作者:
B
Bob Van Landuyt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Free up `avatar`, `group_members` and `milestones` as paths
上级
5d14337b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
87 addition
and
73 deletion
+87
-73
config/routes/group.rb
config/routes/group.rb
+16
-15
lib/gitlab/path_regex.rb
lib/gitlab/path_regex.rb
+0
-3
spec/lib/gitlab/path_regex_spec.rb
spec/lib/gitlab/path_regex_spec.rb
+0
-14
spec/routing/group_routing_spec.rb
spec/routing/group_routing_spec.rb
+71
-11
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+0
-30
未找到文件。
config/routes/group.rb
浏览文件 @
5dde0536
...
...
@@ -20,20 +20,6 @@ constraints(GroupUrlConstrainer.new) do
module: :groups
,
as: :group
,
constraints:
{
group_id:
Gitlab
::
PathRegex
.
full_namespace_route_regex
})
do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
],
concerns: :access_requestable
do
post
:resend_invite
,
on: :member
delete
:leave
,
on: :collection
end
resource
:avatar
,
only:
[
:destroy
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:edit
,
:update
,
:new
,
:create
]
do
member
do
get
:merge_requests
get
:participants
get
:labels
end
end
scope
path:
'-'
do
namespace
:settings
do
resource
:ci_cd
,
only:
[
:show
],
controller:
'ci_cd'
...
...
@@ -46,6 +32,21 @@ constraints(GroupUrlConstrainer.new) do
resources
:labels
,
except:
[
:show
]
do
post
:toggle_subscription
,
on: :member
end
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:edit
,
:update
,
:new
,
:create
]
do
member
do
get
:merge_requests
get
:participants
get
:labels
end
end
resource
:avatar
,
only:
[
:destroy
]
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
],
concerns: :access_requestable
do
post
:resend_invite
,
on: :member
delete
:leave
,
on: :collection
end
end
end
...
...
@@ -62,6 +63,6 @@ constraints(GroupUrlConstrainer.new) do
# Legacy paths should be defined last, so they would be ignored if routes with
# one of the previously reserved words exist.
scope
(
path:
'groups/*group_id'
)
do
Gitlab
::
Routing
.
redirect_legacy_paths
(
self
,
:labels
)
Gitlab
::
Routing
.
redirect_legacy_paths
(
self
,
:labels
,
:milestones
,
:group_members
)
end
end
lib/gitlab/path_regex.rb
浏览文件 @
5dde0536
...
...
@@ -115,15 +115,12 @@ module Gitlab
activity
analytics
audit_events
avatar
edit
group_members
hooks
issues
ldap
ldap_group_links
merge_requests
milestones
notification_setting
pipeline_quota
projects
...
...
spec/lib/gitlab/path_regex_spec.rb
浏览文件 @
5dde0536
...
...
@@ -225,8 +225,6 @@ describe Gitlab::PathRegex do
it
'accepts group routes'
do
expect
(
subject
).
to
match
(
'activity/'
)
expect
(
subject
).
to
match
(
'group_members/'
)
expect
(
subject
).
to
match
(
'labels/'
)
end
it
'is not case sensitive'
do
...
...
@@ -258,8 +256,6 @@ describe Gitlab::PathRegex do
it
'accepts group routes'
do
expect
(
subject
).
to
match
(
'activity/'
)
expect
(
subject
).
to
match
(
'group_members/'
)
expect
(
subject
).
to
match
(
'labels/'
)
end
end
...
...
@@ -280,8 +276,6 @@ describe Gitlab::PathRegex do
it
'accepts group routes'
do
expect
(
subject
).
to
match
(
'activity/more/'
)
expect
(
subject
).
to
match
(
'group_members/more/'
)
expect
(
subject
).
to
match
(
'labels/more/'
)
end
end
end
...
...
@@ -304,8 +298,6 @@ describe Gitlab::PathRegex do
it
'rejects group routes'
do
expect
(
subject
).
not_to
match
(
'root/activity/'
)
expect
(
subject
).
not_to
match
(
'root/group_members/'
)
expect
(
subject
).
not_to
match
(
'root/labels/'
)
end
end
...
...
@@ -326,8 +318,6 @@ describe Gitlab::PathRegex do
it
'rejects group routes'
do
expect
(
subject
).
not_to
match
(
'root/activity/more/'
)
expect
(
subject
).
not_to
match
(
'root/group_members/more/'
)
expect
(
subject
).
not_to
match
(
'root/labels/more/'
)
end
end
end
...
...
@@ -361,8 +351,6 @@ describe Gitlab::PathRegex do
it
'accepts group routes'
do
expect
(
subject
).
to
match
(
'activity/'
)
expect
(
subject
).
to
match
(
'group_members/'
)
expect
(
subject
).
to
match
(
'labels/'
)
end
it
'is not case sensitive'
do
...
...
@@ -394,8 +382,6 @@ describe Gitlab::PathRegex do
it
'accepts group routes'
do
expect
(
subject
).
to
match
(
'root/activity/'
)
expect
(
subject
).
to
match
(
'root/group_members/'
)
expect
(
subject
).
to
match
(
'root/labels/'
)
end
it
'is not case sensitive'
do
...
...
spec/routing/group_routing_spec.rb
浏览文件 @
5dde0536
require
'spec_helper'
describe
'group routing'
do
let!
(
:existing_group
)
{
create
(
:group
,
parent:
create
(
:group
,
path:
'gitlab-org'
),
path:
'infra'
)
}
describe
'GET #labels'
do
it
'routes to the correct controller'
do
expect
(
get
(
'/groups/gitlab-org/infra/-/labels'
))
.
to
route_to
(
group_id:
'gitlab-org/infra'
,
controller:
'groups/labels'
,
action:
'index'
)
describe
"Groups"
,
"routing"
do
let
(
:group_path
)
{
'complex.group-namegit'
}
let!
(
:group
)
{
create
(
:group
,
path:
group_path
)
}
it
"to #show"
do
expect
(
get
(
"/groups/
#{
group_path
}
"
)).
to
route_to
(
'groups#show'
,
id:
group_path
)
end
it
"also supports nested groups"
do
nested_group
=
create
(
:group
,
parent:
group
)
expect
(
get
(
"/
#{
group_path
}
/
#{
nested_group
.
path
}
"
)).
to
route_to
(
'groups#show'
,
id:
"
#{
group_path
}
/
#{
nested_group
.
path
}
"
)
end
it
"also display group#show on the short path"
do
expect
(
get
(
"/
#{
group_path
}
"
)).
to
route_to
(
'groups#show'
,
id:
group_path
)
end
it
"to #activity"
do
expect
(
get
(
"/groups/
#{
group_path
}
/activity"
)).
to
route_to
(
'groups#activity'
,
id:
group_path
)
end
it
"to #issues"
do
expect
(
get
(
"/groups/
#{
group_path
}
/issues"
)).
to
route_to
(
'groups#issues'
,
id:
group_path
)
end
it
"to #members"
do
expect
(
get
(
"/groups/
#{
group_path
}
/-/group_members"
)).
to
route_to
(
'groups/group_members#index'
,
group_id:
group_path
)
end
describe
'legacy redirection'
do
shared_examples
'canonical groups route'
do
|
path
|
it
"
#{
path
}
routes to the correct controller"
do
expect
(
get
(
"/groups/
#{
group_path
}
/-/
#{
path
}
"
))
.
to
route_to
(
group_id:
group_path
,
controller:
"groups/
#{
path
}
"
,
action:
'index'
)
end
it_behaves_like
'redirecting a legacy path'
,
"/groups/complex.group-namegit/
#{
path
}
"
,
"/groups/complex.group-namegit/-/
#{
path
}
/"
do
let
(
:resource
)
{
create
(
:group
,
parent:
group
,
path:
path
)
}
end
end
describe
'labels'
do
it_behaves_like
'canonical groups route'
,
'labels'
end
describe
'group_members'
do
it_behaves_like
'canonical groups route'
,
'group_members'
end
it_behaves_like
'redirecting a legacy path'
,
'/groups/gitlab-org/infra/labels'
,
'/groups/gitlab-org/infra/-/labels'
do
let
(
:resource
)
{
create
(
:group
,
parent:
existing_group
,
path:
'labels'
)
}
describe
'avatar'
do
it
'routes to the avatars controller'
do
expect
(
delete
(
"/groups/
#{
group_path
}
/-/avatar"
))
.
to
route_to
(
group_id:
group_path
,
controller:
'groups/avatars'
,
action:
'destroy'
)
end
end
describe
'milestones'
do
it_behaves_like
'canonical groups route'
,
'milestones'
context
'nested routes'
do
include
RSpec
::
Rails
::
RequestExampleGroup
let
(
:milestone
)
{
create
(
:milestone
,
group:
group
)
}
it
'redirects the nested routes'
do
request
=
get
(
"/groups/
#{
group_path
}
/milestones/
#{
milestone
.
id
}
/merge_requests"
)
expect
(
request
).
to
redirect_to
(
"/groups/
#{
group_path
}
/-/milestones/
#{
milestone
.
id
}
/merge_requests"
)
end
end
end
end
end
spec/routing/routing_spec.rb
浏览文件 @
5dde0536
...
...
@@ -278,36 +278,6 @@ describe "Authentication", "routing" do
end
end
describe
"Groups"
,
"routing"
do
let
(
:name
)
{
'complex.group-namegit'
}
let!
(
:group
)
{
create
(
:group
,
name:
name
)
}
it
"to #show"
do
expect
(
get
(
"/groups/
#{
name
}
"
)).
to
route_to
(
'groups#show'
,
id:
name
)
end
it
"also supports nested groups"
do
nested_group
=
create
(
:group
,
parent:
group
)
expect
(
get
(
"/
#{
name
}
/
#{
nested_group
.
name
}
"
)).
to
route_to
(
'groups#show'
,
id:
"
#{
name
}
/
#{
nested_group
.
name
}
"
)
end
it
"also display group#show on the short path"
do
expect
(
get
(
"/
#{
name
}
"
)).
to
route_to
(
'groups#show'
,
id:
name
)
end
it
"to #activity"
do
expect
(
get
(
"/groups/
#{
name
}
/activity"
)).
to
route_to
(
'groups#activity'
,
id:
name
)
end
it
"to #issues"
do
expect
(
get
(
"/groups/
#{
name
}
/issues"
)).
to
route_to
(
'groups#issues'
,
id:
name
)
end
it
"to #members"
do
expect
(
get
(
"/groups/
#{
name
}
/group_members"
)).
to
route_to
(
'groups/group_members#index'
,
group_id:
name
)
end
end
describe
HealthCheckController
,
'routing'
do
it
'to #index'
do
expect
(
get
(
'/health_check'
)).
to
route_to
(
'health_check#index'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录