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
2ac84e36
Commit
2ac84e36
authored
Feb 24, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport groups API to V3
parent
16150036
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/v3/groups.rb
lib/api/v3/groups.rb
+38
-0
spec/requests/api/v3/groups_spec.rb
spec/requests/api/v3/groups_spec.rb
+35
-0
No files found.
lib/api/api.rb
View file @
2ac84e36
...
...
@@ -10,6 +10,7 @@ module API
mount
::
API
::
V3
::
Commits
mount
::
API
::
V3
::
DeployKeys
mount
::
API
::
V3
::
Files
mount
::
API
::
V3
::
Groups
mount
::
API
::
V3
::
Issues
mount
::
API
::
V3
::
Labels
mount
::
API
::
V3
::
Members
...
...
lib/api/v3/groups.rb
0 → 100644
View file @
2ac84e36
module
API
module
V3
class
Groups
<
Grape
::
API
include
PaginationParams
before
{
authenticate!
}
helpers
do
params
:statistics_params
do
optional
:statistics
,
type:
Boolean
,
default:
false
,
desc:
'Include project statistics'
end
def
present_groups
(
groups
,
options
=
{})
options
=
options
.
reverse_merge
(
with:
::
API
::
Entities
::
Group
,
current_user:
current_user
,
)
groups
=
groups
.
with_statistics
if
options
[
:statistics
]
present
paginate
(
groups
),
options
end
end
resource
:groups
do
desc
'Get list of owned groups for authenticated user'
do
success
::
API
::
Entities
::
Group
end
params
do
use
:pagination
use
:statistics_params
end
get
'/owned'
do
present_groups
current_user
.
owned_groups
,
statistics:
params
[
:statistics
]
end
end
end
end
end
spec/requests/api/v3/groups_spec.rb
0 → 100644
View file @
2ac84e36
require
'spec_helper'
describe
API
::
V3
::
Groups
,
api:
true
do
include
ApiHelpers
include
UploadHelpers
let
(
:user2
)
{
create
(
:user
)
}
let!
(
:group2
)
{
create
(
:group
,
:private
)
}
let!
(
:project2
)
{
create
(
:empty_project
,
namespace:
group2
)
}
before
do
group2
.
add_owner
(
user2
)
end
describe
'GET /groups/owned'
do
context
'when unauthenticated'
do
it
'returns authentication error'
do
get
v3_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
v3_api
(
'/groups/owned'
,
user2
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'name'
]).
to
eq
(
group2
.
name
)
end
end
end
end
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