提交 f09b7f56 编写于 作者: N Nick Thomas

Support hard deletion in Admin::UsersController#destroy

上级 158581a4
...@@ -138,7 +138,7 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -138,7 +138,7 @@ class Admin::UsersController < Admin::ApplicationController
end end
def destroy def destroy
DeleteUserWorker.perform_async(current_user.id, user.id) user.delete_async(deleted_by: current_user, params: params.permit(:hard_delete))
respond_to do |format| respond_to do |format|
format.html { redirect_to admin_users_path, notice: "The user is being deleted." } format.html { redirect_to admin_users_path, notice: "The user is being deleted." }
......
...@@ -25,7 +25,8 @@ Instead of being deleted, these records will be moved to a system-wide ...@@ -25,7 +25,8 @@ Instead of being deleted, these records will be moved to a system-wide
When a user is deleted from an abuse report or spam log, these associated When a user is deleted from an abuse report or spam log, these associated
records are not ghosted and will be removed, along with any groups the user records are not ghosted and will be removed, along with any groups the user
is a sole owner of. Administrators can also request this behaviour when is a sole owner of. Administrators can also request this behaviour when
deleting users from the [API](../../../api/users.md#user-deletion) deleting users from the [API](../../../api/users.md#user-deletion) or the
admin area.
[ce-7393]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7393 [ce-7393]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7393
[ce-10273]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10273 [ce-10273]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10273
......
...@@ -10,15 +10,26 @@ describe Admin::UsersController do ...@@ -10,15 +10,26 @@ describe Admin::UsersController do
describe 'DELETE #user with projects' do describe 'DELETE #user with projects' do
let(:project) { create(:empty_project, namespace: user.namespace) } let(:project) { create(:empty_project, namespace: user.namespace) }
let!(:issue) { create(:issue, author: user) }
before do before do
project.team << [user, :developer] project.team << [user, :developer]
end end
it 'deletes user' do it 'deletes user and ghosts their contributions' do
delete :destroy, id: user.username, format: :json delete :destroy, id: user.username, format: :json
expect(response).to have_http_status(200)
expect(User.exists?(user.id)).to be_falsy
expect(issue.reload.author).to be_ghost
end
it 'deletes the user and their contributions when hard delete is specified' do
delete :destroy, id: user.username, hard_delete: true, format: :json
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect { User.find(user.id) }.to raise_exception(ActiveRecord::RecordNotFound) expect(User.exists?(user.id)).to be_falsy
expect(Issue.exists?(issue.id)).to be_falsy
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册