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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
a29544f5
Commit
a29544f5
authored
Nov 10, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/api_owned_resource' into 'master'
Add api endpoint `/groups/owned` See merge request !7103
parents
0c99e5d0
4f2c4411
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
0 deletions
+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
No files found.
changelogs/unreleased/feature-api_owned_resource.yml
0 → 100644
View file @
a29544f5
---
title
:
Add api endpoint `/groups/owned`
merge_request
:
7103
author
:
Borja Aparicio
doc/api/groups.md
View file @
a29544f5
...
@@ -26,6 +26,15 @@ GET /groups
...
@@ -26,6 +26,15 @@ GET /groups
You can search for groups by name or path, see below.
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
## List a group's projects
Get a list of projects in this group.
Get a list of projects in this group.
...
...
lib/api/groups.rb
View file @
a29544f5
...
@@ -26,6 +26,16 @@ module API
...
@@ -26,6 +26,16 @@ module API
present
@groups
,
with:
Entities
::
Group
present
@groups
,
with:
Entities
::
Group
end
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.
# Create group. Available only for users who can create groups.
#
#
# Parameters:
# Parameters:
...
...
spec/requests/api/groups_spec.rb
View file @
a29544f5
...
@@ -68,6 +68,24 @@ describe API::API, api: true do
...
@@ -68,6 +68,24 @@ describe API::API, api: true do
end
end
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
describe
"GET /groups/:id"
do
context
"when authenticated as user"
do
context
"when authenticated as user"
do
it
"returns one of user1's groups"
do
it
"returns one of user1's groups"
do
...
...
spec/requests/api/projects_spec.rb
View file @
a29544f5
...
@@ -175,6 +175,30 @@ describe API::API, api: true do
...
@@ -175,6 +175,30 @@ describe API::API, api: true do
end
end
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
describe
'GET /projects/visible'
do
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
let
(
:public_project
)
{
create
(
:project
,
:public
)
}
...
...
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