Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a29544f5
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,发现更多精彩内容 >>
提交
a29544f5
编写于
11月 10, 2016
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/api_owned_resource' into 'master'
Add api endpoint `/groups/owned` See merge request !7103
上级
0c99e5d0
4f2c4411
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
65 addition
and
0 deletion
+65
-0
changelogs/unreleased/feature-api_owned_resource.yml
changelogs/unreleased/feature-api_owned_resource.yml
+4
-0
doc/api/groups.md
doc/api/groups.md
+9
-0
lib/api/groups.rb
lib/api/groups.rb
+10
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+18
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+24
-0
未找到文件。
changelogs/unreleased/feature-api_owned_resource.yml
0 → 100644
浏览文件 @
a29544f5
---
title
:
Add api endpoint `/groups/owned`
merge_request
:
7103
author
:
Borja Aparicio
doc/api/groups.md
浏览文件 @
a29544f5
...
...
@@ -26,6 +26,15 @@ GET /groups
You can search for groups by name or path, see below.
=======
## List owned groups
Get a list of groups which are owned by the authenticated user.
```
GET /groups/owned
```
## List a group's projects
Get a list of projects in this group.
...
...
lib/api/groups.rb
浏览文件 @
a29544f5
...
...
@@ -26,6 +26,16 @@ module API
present
@groups
,
with:
Entities
::
Group
end
# Get list of owned groups for authenticated user
#
# Example Request:
# GET /groups/owned
get
'/owned'
do
@groups
=
current_user
.
owned_groups
@groups
=
paginate
@groups
present
@groups
,
with:
Entities
::
Group
,
user:
current_user
end
# Create group. Available only for users who can create groups.
#
# Parameters:
...
...
spec/requests/api/groups_spec.rb
浏览文件 @
a29544f5
...
...
@@ -68,6 +68,24 @@ describe API::API, api: true do
end
end
describe
'GET /groups/owned'
do
context
'when unauthenticated'
do
it
'returns authentication error'
do
get
api
(
'/groups/owned'
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
context
'when authenticated as group owner'
do
it
'returns an array of groups the user owns'
do
get
api
(
'/groups/owned'
,
user2
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
group2
.
name
)
end
end
end
describe
"GET /groups/:id"
do
context
"when authenticated as user"
do
it
"returns one of user1's groups"
do
...
...
spec/requests/api/projects_spec.rb
浏览文件 @
a29544f5
...
...
@@ -175,6 +175,30 @@ describe API::API, api: true do
end
end
describe
'GET /projects/owned'
do
before
do
project3
project4
end
context
'when unauthenticated'
do
it
'returns authentication error'
do
get
api
(
'/projects/owned'
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
context
'when authenticated as project owner'
do
it
'returns an array of projects the user owns'
do
get
api
(
'/projects/owned'
,
user4
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
project4
.
name
)
expect
(
json_response
.
first
[
'owner'
][
'username'
]).
to
eq
(
user4
.
username
)
end
end
end
describe
'GET /projects/visible'
do
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录