Skip to content
Snippets Groups Projects
Commit 6c190d27 authored by Stan Hu's avatar Stan Hu Committed by Robert Speicher
Browse files

Move API group deletion to Sidekiq

parent d6c8a551
No related branches found
No related tags found
No related merge requests found
---
title: Move API group deletion to Sidekiq
merge_request:
author:
type: changed
Loading
Loading
@@ -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.
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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(204)
expect(response).to have_gitlab_http_status(202)
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
Loading
Loading
@@ -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(204)
expect(response).to have_gitlab_http_status(202)
end
 
it "does not remove a non existing group" do
Loading
Loading
Loading
Loading
@@ -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(200)
expect(response).to have_gitlab_http_status(202)
end
 
it "does not remove a group if not an owner" do
Loading
Loading
@@ -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(200)
expect(response).to have_gitlab_http_status(202)
end
 
it "does not remove a non existing group" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment