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
Léo-Paul Géneau
gitlab-ce
Commits
16150036
Commit
16150036
authored
Feb 24, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Use parameter to get owned groups instead of dedicated endpoint
parent
c5b29ed6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
24 deletions
+6
-24
lib/api/groups.rb
lib/api/groups.rb
+4
-12
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+2
-12
No files found.
lib/api/groups.rb
View file @
16150036
...
...
@@ -36,12 +36,15 @@ module API
optional
:skip_groups
,
type:
Array
[
Integer
],
desc:
'Array of group ids to exclude from list'
optional
:all_available
,
type:
Boolean
,
desc:
'Show all group that you have access to'
optional
:search
,
type:
String
,
desc:
'Search for a specific group'
optional
:owned
,
type:
Boolean
,
default:
false
,
desc:
'Limit by owned by authenticated user'
optional
:order_by
,
type:
String
,
values:
%w[name path]
,
default:
'name'
,
desc:
'Order by name or path'
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'asc'
,
desc:
'Sort by asc (ascending) or desc (descending)'
use
:pagination
end
get
do
groups
=
if
current_user
.
admin
groups
=
if
params
[
:owned
]
current_user
.
owned_groups
elsif
current_user
.
admin
Group
.
all
elsif
params
[
:all_available
]
GroupsFinder
.
new
.
execute
(
current_user
)
...
...
@@ -56,17 +59,6 @@ module API
present_groups
groups
,
statistics:
params
[
:statistics
]
&&
current_user
.
is_admin?
end
desc
'Get list of owned groups for authenticated user'
do
success
Entities
::
Group
end
params
do
use
:pagination
use
:statistics_params
end
get
'/owned'
do
present_groups
current_user
.
owned_groups
,
statistics:
params
[
:statistics
]
end
desc
'Create a group. Available only for users who can create groups.'
do
success
Entities
::
Group
end
...
...
spec/requests/api/groups_spec.rb
View file @
16150036
...
...
@@ -150,20 +150,10 @@ describe API::Groups, api: true do
expect
(
response_groups
).
to
eq
([
group1
.
name
,
group3
.
name
])
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
context
'when
using owned in the request
'
do
it
'returns an array of groups the user owns'
do
get
api
(
'/groups
/owned'
,
user2
)
get
api
(
'/groups
'
,
user2
),
owned:
true
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
...
...
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