Commit 4bcc0977 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

A worker deletes a user, so the request doesn't time out

Fixes #13261
parent bc590ce6
...@@ -178,6 +178,7 @@ v 8.5.0 ...@@ -178,6 +178,7 @@ v 8.5.0
v 8.4.5 v 8.4.5
- No CE-specific changes - No CE-specific changes
- User deletion is now done in the background so the request can not time out
v 8.4.4 v 8.4.4
- Update omniauth-saml gem to 1.4.2 - Update omniauth-saml gem to 1.4.2
......
...@@ -122,7 +122,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -122,7 +122,7 @@ class Admin::UsersController < Admin::ApplicationController
DeleteUserService.new(current_user).execute(user) DeleteUserService.new(current_user).execute(user)
respond_to do |format| respond_to do |format|
format.html { redirect_to admin_users_path } format.html { redirect_to admin_users_path, notice: "The user is being deleted." }
format.json { head :ok } format.json { head :ok }
end end
end end
......
class DeleteUserWorker
include Sidekiq::Worker
def perform(current_user_id, delete_user_id)
delete_user = User.find(delete_user_id)
current_user = User.find(current_user_id)
DeleteUserService.new(current_user).execute(delete_user)
end
end
require 'spec_helper'
describe DeleteUserWorker do
describe "Deletes a user and all their personal projects" do
let!(:user) { create(:user) }
let!(:current_user) { create(:user) }
let!(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace) }
before do
DeleteUserWorker.new.perform(current_user.id, user.id)
end
it 'deletes all personal projects' do
expect { Project.find(project.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'deletes the user' do
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment