summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJames Lopez <james@gitlab.com>2019-04-02 06:49:12 +0000
committerJames Lopez <james@gitlab.com>2019-04-02 06:49:12 +0000
commitc44b9e9e5b79c4012a0fea8743fc058a444234d0 (patch)
tree363f91b4822d32bdccb927af1d80d081beb76a7d /spec
parentba23d6377c650ecaac420c8085a2cd82737d3ced (diff)
parent22fe2fb4c11c16739a3a1bb97569884db70ac546 (diff)
downloadgitlab-ce-c44b9e9e5b79c4012a0fea8743fc058a444234d0.tar.gz
Merge branch 'fix-transfer-group-possibilities' into 'master'
Fix group transfer selection possibilities Closes #52295 See merge request gitlab-org/gitlab-ce!26123
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/groups_helper_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 91541a16c13..1763c46389a 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -229,4 +229,37 @@ describe GroupsHelper do
expect(helper.group_sidebar_links).not_to include(*cross_project_features)
end
end
+
+ describe 'parent_group_options', :nested_groups do
+ let(:current_user) { create(:user) }
+ let(:group) { create(:group, name: 'group') }
+ let(:group2) { create(:group, name: 'group2') }
+
+ before do
+ group.add_owner(current_user)
+ group2.add_owner(current_user)
+ end
+
+ it 'includes explicitly owned groups except self' do
+ expect(parent_group_options(group2)).to eq([{ id: group.id, text: group.human_name }].to_json)
+ end
+
+ it 'excludes parent group' do
+ subgroup = create(:group, parent: group2)
+
+ expect(parent_group_options(subgroup)).to eq([{ id: group.id, text: group.human_name }].to_json)
+ end
+
+ it 'includes subgroups with inherited ownership' do
+ subgroup = create(:group, parent: group)
+
+ expect(parent_group_options(group2)).to eq([{ id: group.id, text: group.human_name }, { id: subgroup.id, text: subgroup.human_name }].to_json)
+ end
+
+ it 'excludes own subgroups' do
+ create(:group, parent: group2)
+
+ expect(parent_group_options(group2)).to eq([{ id: group.id, text: group.human_name }].to_json)
+ end
+ end
end