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
iv
gitlab-ce
Commits
dc825ae3
Commit
dc825ae3
authored
Oct 07, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/api_remove_group' of /home/git/repositories/gitlab/gitlabhq
parents
2eb76186
93341579
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
2 deletions
+68
-2
CHANGELOG
CHANGELOG
+1
-0
doc/api/groups.md
doc/api/groups.md
+13
-0
lib/api/groups.rb
lib/api/groups.rb
+16
-2
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+38
-0
No files found.
CHANGELOG
View file @
dc825ae3
...
...
@@ -12,6 +12,7 @@ v 6.2.0
- Update logic for validates_merge_request for tree of MR (Andrew Kumanyaev)
- Rake tasks for web hooks management (Jonhnny Weslley)
- Extended User API to expose admin and can_create_group for user creation/updating (Boyan Tabakov)
- API: Remove group
v 6.1.0
- Project specific IDs for issues, mr, milestones
...
...
doc/api/groups.md
View file @
dc825ae3
...
...
@@ -57,6 +57,19 @@ Parameters:
+
`project_id`
(required) - The ID of a project
## Remove group
Removes group with all projects inside.
```
DELETE /groups/:id
```
Parameters:
+
`id`
(required) - The ID of a user group
## Group members
...
...
lib/api/groups.rb
View file @
dc825ae3
...
...
@@ -7,12 +7,14 @@ module API
helpers
do
def
find_group
(
id
)
group
=
Group
.
find
(
id
)
if
current_user
.
admin
or
current_user
.
groups
.
include?
group
if
can?
(
current_user
,
:read_group
,
group
)
group
else
render_api_error!
(
"403 Forbidden -
#{
current_user
.
username
}
lacks sufficient access to
#{
group
.
name
}
"
,
403
)
end
end
def
validate_access_level?
(
level
)
Gitlab
::
Access
.
options_with_owner
.
values
.
include?
level
.
to_i
end
...
...
@@ -64,6 +66,19 @@ module API
present
group
,
with:
Entities
::
GroupDetail
end
# Remove group
#
# Parameters:
# id (required) - The ID of a group
# Example Request:
# DELETE /groups/:id
delete
":id"
do
group
=
find_group
(
params
[
:id
])
authorize!
:manage_group
,
group
group
.
destroy
end
# Transfer a project to the Group namespace
#
# Parameters:
...
...
@@ -132,7 +147,6 @@ module API
member
.
destroy
end
end
end
end
end
spec/requests/api/groups_spec.rb
View file @
dc825ae3
...
...
@@ -106,6 +106,44 @@ describe API::API do
end
end
describe
"DELETE /groups/:id"
do
context
"when authenticated as user"
do
it
"should remove group"
do
delete
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
)
response
.
status
.
should
==
200
end
it
"should not remove a group if not an owner"
do
user3
=
create
(
:user
)
group1
.
add_user
(
user3
,
Gitlab
::
Access
::
MASTER
)
delete
api
(
"/groups/
#{
group1
.
id
}
"
,
user3
)
response
.
status
.
should
==
403
end
it
"should not remove a non existing group"
do
delete
api
(
"/groups/1328"
,
user1
)
response
.
status
.
should
==
404
end
it
"should not remove a group not attached to user1"
do
delete
api
(
"/groups/
#{
group2
.
id
}
"
,
user1
)
response
.
status
.
should
==
403
end
end
context
"when authenticated as admin"
do
it
"should remove any existing group"
do
delete
api
(
"/groups/
#{
group2
.
id
}
"
,
admin
)
response
.
status
.
should
==
200
end
it
"should not remove a non existing group"
do
delete
api
(
"/groups/1328"
,
admin
)
response
.
status
.
should
==
404
end
end
end
describe
"POST /groups/:id/projects/:project_id"
do
let
(
:project
)
{
create
(
:project
)
}
before
(
:each
)
do
...
...
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