diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-11-25 11:26:28 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-12-05 00:16:44 +0300 |
commit | 9c5977c821c1958709227a7a5976e1faedc53923 (patch) | |
tree | 474840a3b973cb199974dc4aab179b0b23c4ed1e /spec | |
parent | 703233e1e9ce8572740b7f22ea62b2a59015e564 (diff) |
Teach Project about #all_clusters
This returns a union of the project level clusters and group level
clusters associated with this project.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index edb9ff4e734..5cce8d87c96 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -3984,6 +3984,27 @@ describe Project do end end + describe '#all_clusters' do + let(:project) { create(:project) } + let(:cluster) { create(:cluster, cluster_type: :project_type, projects: [project]) } + + subject { project.all_clusters } + + it 'returns project level cluster' do + expect(subject).to eq([cluster]) + end + + context 'project belongs to a group' do + let(:group_cluster) { create(:cluster, :group) } + let(:group) { group_cluster.group } + let(:project) { create(:project, group: group) } + + it 'returns clusters for groups of this project' do + expect(subject).to contain_exactly(cluster, group_cluster) + end + end + end + def rugged_config rugged_repo(project.repository).config end |