diff options
author | Peter Marko <peter.marko@siemens.com> | 2019-04-02 09:49:11 +0300 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-04-02 09:49:11 +0300 |
commit | 22fe2fb4c11c16739a3a1bb97569884db70ac546 (patch) | |
tree | 363f91b4822d32bdccb927af1d80d081beb76a7d /spec/helpers | |
parent | ba23d6377c650ecaac420c8085a2cd82737d3ced (diff) |
Fix group transfer selection possibilities
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 33 |
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 |