diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 15:07:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-13 15:07:53 +0000 |
commit | a5ab3467a705b62911feacc3cf627fdbb00aa198 (patch) | |
tree | 65143ce13405efccb922fc428624ad57c38b6efa /spec/models/group_spec.rb | |
parent | eb30dd6e28f6fc9eb8021d205f6ed84511f001e2 (diff) | |
download | gitlab-ce-a5ab3467a705b62911feacc3cf627fdbb00aa198.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/group_spec.rb')
-rw-r--r-- | spec/models/group_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 842acf92c2a..3531c695236 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -1003,6 +1003,57 @@ describe Group do end end + describe '#related_group_ids' do + let(:nested_group) { create(:group, parent: group) } + let(:shared_with_group) { create(:group, parent: group) } + + before do + create(:group_group_link, shared_group: nested_group, + shared_with_group: shared_with_group) + end + + subject(:related_group_ids) { nested_group.related_group_ids } + + it 'returns id' do + expect(related_group_ids).to include(nested_group.id) + end + + it 'returns ancestor id' do + expect(related_group_ids).to include(group.id) + end + + it 'returns shared with group id' do + expect(related_group_ids).to include(shared_with_group.id) + end + + context 'with more than one ancestor group' do + let(:ancestor_group) { create(:group) } + + before do + group.update(parent: ancestor_group) + end + + it 'returns all ancestor group ids' do + expect(related_group_ids).to( + include(group.id, ancestor_group.id)) + end + end + + context 'with more than one shared with group' do + let(:another_shared_with_group) { create(:group, parent: group) } + + before do + create(:group_group_link, shared_group: nested_group, + shared_with_group: another_shared_with_group) + end + + it 'returns all shared with group ids' do + expect(related_group_ids).to( + include(shared_with_group.id, another_shared_with_group.id)) + end + end + end + context 'with uploads' do it_behaves_like 'model with uploads', true do let(:model_object) { create(:group, :with_avatar) } |