diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 12:29:45 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 13:05:45 +0100 |
commit | a4fc8112df3cf6cb344cfba65f5df46c7a99bef7 (patch) | |
tree | e710eccab33d56e73bc70a3d172d9c917ae0bd7e /spec | |
parent | a74d6d204366c862657a545d999cb33dfde300dd (diff) | |
download | gitlab-ce-a4fc8112df3cf6cb344cfba65f5df46c7a99bef7.tar.gz |
Added Project.visible_to_user
This method can be used to filter projects to those visible to a given
user.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 8d7e6e76766..c42e8870f8c 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -464,4 +464,23 @@ describe Project do end end end + + describe '.visible_to_user' do + let!(:project) { create(:project, :private) } + let!(:user) { create(:user) } + + subject { described_class.visible_to_user(user) } + + describe 'when a user has access to a project' do + before do + project.team.add_user(user, Gitlab::Access::MASTER) + end + + it { is_expected.to eq([project]) } + end + + describe 'when a user does not have access to any projects' do + it { is_expected.to eq([]) } + end + end end |