summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-02 15:10:40 +0000
committerDouwe Maan <douwe@gitlab.com>2017-06-02 15:10:40 +0000
commitf123b6523328cec6445b32977f913e565f3965da (patch)
tree5fc659f57f6e72b0bf9e4c5622f15c2d2bcb485c /spec/services
parentde3e1bb4ecccaf6d5dfa26140cbfc567dd998979 (diff)
parent7db09c63cc4532acea2d736f667b36c96b22007d (diff)
downloadgitlab-ce-f123b6523328cec6445b32977f913e565f3965da.tar.gz
Merge branch '33215-fix-hard-delete-of-users' into 'master'
Fix hard-deleting users when they have authored issues Closes #33215 See merge request !11855
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/users/destroy_service_spec.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/services/users/destroy_service_spec.rb b/spec/services/users/destroy_service_spec.rb
index de37a61e388..5409f67c091 100644
--- a/spec/services/users/destroy_service_spec.rb
+++ b/spec/services/users/destroy_service_spec.rb
@@ -147,16 +147,22 @@ describe Users::DestroyService, services: true do
end
context "migrating associated records" do
+ let!(:issue) { create(:issue, author: user) }
+
it 'delegates to the `MigrateToGhostUser` service to move associated records to the ghost user' do
- expect_any_instance_of(Users::MigrateToGhostUserService).to receive(:execute).once
+ expect_any_instance_of(Users::MigrateToGhostUserService).to receive(:execute).once.and_call_original
service.execute(user)
+
+ expect(issue.reload.author).to be_ghost
end
it 'does not run `MigrateToGhostUser` if hard_delete option is given' do
expect_any_instance_of(Users::MigrateToGhostUserService).not_to receive(:execute)
service.execute(user, hard_delete: true)
+
+ expect(Issue.exists?(issue.id)).to be_falsy
end
end
end