diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-12-07 07:47:41 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-12-17 09:51:53 +1300 |
commit | 2ad5f999e95ed0627e2c8aea9da670b7da559bab (patch) | |
tree | 2174d4ea0a9b26828efe0e7aedf9f6e23788085a /spec/finders | |
parent | 0e78834bc939980e40aef65b6b51f29293dab6d9 (diff) | |
download | gitlab-ce-2ad5f999e95ed0627e2c8aea9da670b7da559bab.tar.gz |
Check can :read_clusters in finder
This is in addtion to the can checks we have in the controller, as a
finder can be used elsewhere in the future.
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/cluster_ancestors_finder_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/finders/cluster_ancestors_finder_spec.rb b/spec/finders/cluster_ancestors_finder_spec.rb index c1897ef9077..332086c42e2 100644 --- a/spec/finders/cluster_ancestors_finder_spec.rb +++ b/spec/finders/cluster_ancestors_finder_spec.rb @@ -20,6 +20,10 @@ describe ClusterAncestorsFinder, '#execute' do context 'for a project' do let(:clusterable) { project } + before do + project.add_maintainer(user) + end + it 'returns the project clusters followed by group clusters' do is_expected.to eq([project_cluster, group_cluster]) end @@ -38,9 +42,21 @@ describe ClusterAncestorsFinder, '#execute' do end end + context 'user cannot read clusters for clusterable' do + let(:clusterable) { project } + + it 'returns nothing' do + is_expected.to be_empty + end + end + context 'for a group' do let(:clusterable) { group } + before do + group.add_maintainer(user) + end + it 'returns the list of group clusters' do is_expected.to eq([group_cluster]) end |