summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2016-03-04 09:49:23 +0100
committerZeger-Jan van de Weg <zegerjan@gitlab.com>2016-03-15 21:09:25 +0100
commitd249da1c16bea8f9d340520168c64794c5f78928 (patch)
tree546abee4069e986e88f001b477324a8563d8294c /spec/workers
parentb221d11a25218d3c2ad5304be91c849e1872be6c (diff)
downloadgitlab-ce-d249da1c16bea8f9d340520168c64794c5f78928.tar.gz
Specs on force deleting of a user
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/delete_user_worker_spec.rb48
1 files changed, 42 insertions, 6 deletions
diff --git a/spec/workers/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb
index 73005c507c6..bec9aecb48c 100644
--- a/spec/workers/delete_user_worker_spec.rb
+++ b/spec/workers/delete_user_worker_spec.rb
@@ -7,16 +7,52 @@ describe DeleteUserWorker do
let!(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace) }
- before do
- DeleteUserWorker.new.perform(current_user.id, user.id)
+ context 'no force flag given' do
+ 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
- it 'deletes all personal projects' do
- expect { Project.find(project.id) }.to raise_error(ActiveRecord::RecordNotFound)
+ context "solo owned groups present" do
+ let(:solo_owned) { create(:group) }
+ let(:member) { create(:group_member) }
+ let(:user) { user = member.user }
+
+ before do
+ solo_owned.group_members = [member]
+ DeleteUserWorker.new.perform(current_user.id, user.id)
+ end
+
+ it 'does not delete the user' do
+ expect(User.find(user.id)).to eq user
+ end
end
- it 'deletes the user' do
- expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
+ context "deletions with force" do
+ let(:solo_owned) { create(:group) }
+ let(:member) { create(:group_member) }
+ let(:user) { user = member.user }
+
+ before do
+ solo_owned.group_members = [member]
+ DeleteUserWorker.new.perform(current_user.id, user.id, "force" => true)
+ end
+
+ it 'deletes solo owned groups' do
+ expect { Project.find(solo_owned.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
end