summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-28 12:00:02 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-28 12:00:02 +0200
commit499154518a1555523ed5f203c9ce4bbe6317c9a5 (patch)
treea353b24c08673cfdc4f0c9cb8617e8c57af822a4 /spec/models/user_spec.rb
parentc843e092f309d22281205e34658221f17642ea33 (diff)
downloadgitlab-ce-499154518a1555523ed5f203c9ce4bbe6317c9a5.tar.gz
You can not remove user if he/she is an only owner of group
To prevent loose of group data you need to transfer or remove group first before you can remove user Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index e1205c18a85..49c7b7d99ce 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -572,7 +572,6 @@ describe User do
end
describe "#contributed_projects_ids" do
-
subject { create(:user) }
let!(:project1) { create(:project) }
let!(:project2) { create(:project, forked_from_project: project3) }
@@ -598,4 +597,21 @@ describe User do
expect(subject.contributed_projects_ids).not_to include(project2.id)
end
end
+
+ describe :can_be_removed? do
+ subject { create(:user) }
+
+ context 'no owned groups' do
+ it { expect(subject.can_be_removed?).to be_truthy }
+ end
+
+ context 'has owned groups' do
+ before do
+ group = create(:group)
+ group.add_owner(subject)
+ end
+
+ it { expect(subject.can_be_removed?).to be_falsey }
+ end
+ end
end