Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b359d5d5
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,体验更适合开发者的 AI 搜索 >>
提交
b359d5d5
编写于
5月 24, 2016
作者:
S
Stan Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix groups API to list only user's accessible projects
Closes #17496
上级
d6e5299f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
6 deletion
+21
-6
CHANGELOG
CHANGELOG
+1
-0
app/finders/group_projects_finder.rb
app/finders/group_projects_finder.rb
+1
-1
lib/api/groups.rb
lib/api/groups.rb
+1
-2
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+18
-3
未找到文件。
CHANGELOG
浏览文件 @
b359d5d5
...
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.9.0 (unreleased)
- Redesign navigation for project pages
- Fix groups API to list only user's accessible projects
- Use gitlab-shell v3.0.0
v 8.8.2 (unreleased)
...
...
app/finders/group_projects_finder.rb
浏览文件 @
b359d5d5
...
...
@@ -18,7 +18,7 @@ class GroupProjectsFinder < UnionFinder
projects
=
[]
if
current_user
if
@group
.
users
.
include?
(
current_user
)
if
@group
.
users
.
include?
(
current_user
)
||
current_user
.
admin?
projects
<<
@group
.
projects
unless
only_shared
projects
<<
@group
.
shared_projects
unless
only_owned
else
...
...
lib/api/groups.rb
浏览文件 @
b359d5d5
...
...
@@ -95,8 +95,7 @@ module API
# GET /groups/:id/projects
get
":id/projects"
do
group
=
find_group
(
params
[
:id
])
projects
=
group
.
projects
projects
=
filter_projects
(
projects
)
projects
=
GroupProjectsFinder
.
new
(
group
).
execute
(
current_user
)
projects
=
paginate
projects
present
projects
,
with:
Entities
::
Project
end
...
...
spec/requests/api/groups_spec.rb
浏览文件 @
b359d5d5
...
...
@@ -12,6 +12,7 @@ describe API::API, api: true do
let!
(
:group2
)
{
create
(
:group
,
:private
)
}
let!
(
:project1
)
{
create
(
:project
,
namespace:
group1
)
}
let!
(
:project2
)
{
create
(
:project
,
namespace:
group2
)
}
let!
(
:project3
)
{
create
(
:project
,
namespace:
group1
,
path:
'test'
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
}
before
do
group1
.
add_owner
(
user1
)
...
...
@@ -147,9 +148,11 @@ describe API::API, api: true do
context
"when authenticated as user"
do
it
"should return the group's projects"
do
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project1
.
name
)
expect
(
json_response
.
length
).
to
eq
(
2
)
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
end
it
"should not return a non existing group"
do
...
...
@@ -162,6 +165,16 @@ describe API::API, api: true do
expect
(
response
.
status
).
to
eq
(
404
)
end
it
"should only return projects to which user has access"
do
project3
.
team
<<
[
user3
,
:developer
]
get
api
(
"/groups/
#{
group1
.
id
}
/projects"
,
user3
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project3
.
name
)
end
end
context
"when authenticated as admin"
do
...
...
@@ -181,8 +194,10 @@ describe API::API, api: true do
context
'when using group path in URL'
do
it
'should return any existing group'
do
get
api
(
"/groups/
#{
group1
.
path
}
/projects"
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project1
.
name
)
project_names
=
json_response
.
map
{
|
proj
|
proj
[
'name'
]
}
expect
(
project_names
).
to
match_array
([
project1
.
name
,
project3
.
name
])
end
it
'should not return a non existing group'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录