diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 14:27:21 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 15:05:45 +0300 |
commit | a74d6d204366c862657a545d999cb33dfde300dd (patch) | |
tree | 9737b222b3e549a306b5015609e76f2ee961c581 /spec | |
parent | 01620dd7e7f3015e31ac0288ef71fcfc4f268a14 (diff) |
Group methods for filtering public/visible groups
These methods will be used to get a list of groups, optionally
restricted to only those visible to a given user.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/group_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index bbfc5535eec..6f166b5ab75 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -38,6 +38,33 @@ describe Group do it { is_expected.not_to validate_presence_of :owner } end + describe '.public_and_given_groups' do + let!(:public_group) { create(:group, public: true) } + + subject { described_class.public_and_given_groups([group.id]) } + + it { is_expected.to eq([public_group, group]) } + end + + describe '.visible_to_user' do + let!(:group) { create(:group) } + let!(:user) { create(:user) } + + subject { described_class.visible_to_user(user) } + + describe 'when the user has access to a group' do + before do + group.add_user(user, Gitlab::Access::MASTER) + end + + it { is_expected.to eq([group]) } + end + + describe 'when the user does not have access to any groups' do + it { is_expected.to eq([]) } + end + end + describe '#to_reference' do it 'returns a String reference to the object' do expect(group.to_reference).to eq "@#{group.name}" |