Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
d965e4e6fc5a
Commit
1cdb299c
authored
May 18, 2018
by
Stan Hu
Committed by
Robert Speicher
May 18, 2018
Browse files
Move API group deletion to Sidekiq
parent
6ee91b483d32
Changes
6
Hide whitespace changes
Inline
Side-by-side
changelogs/unreleased/sh-move-delete-groups-api-async.yml
0 → 100644
View file @
d965e4e6
---
title
:
Move API group deletion to Sidekiq
merge_request
:
author
:
type
:
changed
doc/api/groups.md
View file @
d965e4e6
...
...
@@ -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 @
d965e4e6
...
...
@@ -167,8 +167,10 @@ def present_groups(params, groups)
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 @
d965e4e6
...
...
@@ -131,8 +131,9 @@ def present_groups(groups, options = {})
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 @
d965e4e6
...
...
@@ -738,13 +738,16 @@ def add_projects_to_group(group, share_with: nil)
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 @@ def add_projects_to_group(group, share_with: nil)
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 @
d965e4e6
...
...
@@ -458,9 +458,11 @@
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 @@
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