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
Jérome Perrin
gitlab-ce
Commits
6c190d27
Commit
6c190d27
authored
May 18, 2018
by
Stan Hu
Committed by
Robert Speicher
May 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move API group deletion to Sidekiq
parent
d6c8a551
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
9 deletions
+25
-9
changelogs/unreleased/sh-move-delete-groups-api-async.yml
changelogs/unreleased/sh-move-delete-groups-api-async.yml
+5
-0
doc/api/groups.md
doc/api/groups.md
+3
-0
lib/api/groups.rb
lib/api/groups.rb
+3
-1
lib/api/v3/groups.rb
lib/api/v3/groups.rb
+3
-2
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+6
-3
spec/requests/api/v3/groups_spec.rb
spec/requests/api/v3/groups_spec.rb
+5
-3
No files found.
changelogs/unreleased/sh-move-delete-groups-api-async.yml
0 → 100644
View file @
6c190d27
---
title
:
Move API group deletion to Sidekiq
merge_request
:
author
:
type
:
changed
doc/api/groups.md
View file @
6c190d27
...
...
@@ -487,6 +487,9 @@ Parameters:
-
`id`
(required) - The ID or path of a user group
This will queue a background job to delete all projects in the group. The
response will be a 202 Accepted if the user has authorization.
## Search for group
Get all groups that match your string in their name or path.
...
...
lib/api/groups.rb
View file @
6c190d27
...
...
@@ -167,8 +167,10 @@ module API
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/46285'
)
destroy_conditionally!
(
group
)
do
|
group
|
::
Groups
::
DestroyService
.
new
(
group
,
current_user
).
execute
::
Groups
::
DestroyService
.
new
(
group
,
current_user
).
async_
execute
end
accepted!
end
desc
'Get a list of projects in this group.'
do
...
...
lib/api/v3/groups.rb
View file @
6c190d27
...
...
@@ -131,8 +131,9 @@ module API
delete
":id"
do
group
=
find_group!
(
params
[
:id
])
authorize!
:admin_group
,
group
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-ce/issues/46285'
)
present
::
Groups
::
DestroyService
.
new
(
group
,
current_user
).
execute
,
with:
Entities
::
GroupDetail
,
current_user:
current_user
::
Groups
::
DestroyService
.
new
(
group
,
current_user
).
async_execute
accepted!
end
desc
'Get a list of projects in this group.'
do
...
...
spec/requests/api/groups_spec.rb
View file @
6c190d27
...
...
@@ -738,13 +738,16 @@ describe API::Groups do
describe
"DELETE /groups/:id"
do
context
"when authenticated as user"
do
it
"removes group"
do
delete
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
)
Sidekiq
::
Testing
.
fake!
do
expect
{
delete
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
)
}.
to
change
(
GroupDestroyWorker
.
jobs
,
:size
).
by
(
1
)
end
expect
(
response
).
to
have_gitlab_http_status
(
20
4
)
expect
(
response
).
to
have_gitlab_http_status
(
20
2
)
end
it_behaves_like
'412 response'
do
let
(
:request
)
{
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
)
}
let
(
:success_status
)
{
202
}
end
it
"does not remove a group if not an owner"
do
...
...
@@ -773,7 +776,7 @@ describe API::Groups do
it
"removes any existing group"
do
delete
api
(
"/groups/
#{
group2
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
20
4
)
expect
(
response
).
to
have_gitlab_http_status
(
20
2
)
end
it
"does not remove a non existing group"
do
...
...
spec/requests/api/v3/groups_spec.rb
View file @
6c190d27
...
...
@@ -458,9 +458,11 @@ describe API::V3::Groups do
describe
"DELETE /groups/:id"
do
context
"when authenticated as user"
do
it
"removes group"
do
delete
v3_api
(
"/groups/
#{
group1
.
id
}
"
,
user1
)
Sidekiq
::
Testing
.
fake!
do
expect
{
delete
v3_api
(
"/groups/
#{
group1
.
id
}
"
,
user1
)
}.
to
change
(
GroupDestroyWorker
.
jobs
,
:size
).
by
(
1
)
end
expect
(
response
).
to
have_gitlab_http_status
(
20
0
)
expect
(
response
).
to
have_gitlab_http_status
(
20
2
)
end
it
"does not remove a group if not an owner"
do
...
...
@@ -489,7 +491,7 @@ describe API::V3::Groups do
it
"removes any existing group"
do
delete
v3_api
(
"/groups/
#{
group2
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
20
0
)
expect
(
response
).
to
have_gitlab_http_status
(
20
2
)
end
it
"does not remove a non existing group"
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