diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-11-07 01:13:33 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-12-17 09:50:52 +1300 |
commit | 7e4f76ea8978bfff42124013cd38ed5ad38873b5 (patch) | |
tree | fdcb69f5bf201507befe953085067bc47a27c839 /spec/finders | |
parent | 8b4602041cf2c4a8738a4796d78720017249249f (diff) | |
download | gitlab-ce-7e4f76ea8978bfff42124013cd38ed5ad38873b5.tar.gz |
Show clusters of ancestors in cluster list page
Show both the cluster(s) of the clusterable, and the cluster(s) of
ancestor groups.
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/cluster_ancestors_finder_spec.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/finders/cluster_ancestors_finder_spec.rb b/spec/finders/cluster_ancestors_finder_spec.rb new file mode 100644 index 00000000000..c1897ef9077 --- /dev/null +++ b/spec/finders/cluster_ancestors_finder_spec.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ClusterAncestorsFinder, '#execute' do + let(:group) { create(:group) } + let(:project) { create(:project, group: group) } + let(:user) { create(:user) } + + let!(:project_cluster) do + create(:cluster, :provided_by_user, cluster_type: :project_type, projects: [project]) + end + + let!(:group_cluster) do + create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [group]) + end + + subject { described_class.new(clusterable, user).execute } + + context 'for a project' do + let(:clusterable) { project } + + it 'returns the project clusters followed by group clusters' do + is_expected.to eq([project_cluster, group_cluster]) + end + + context 'nested groups', :nested_groups do + let(:group) { create(:group, parent: parent_group) } + let(:parent_group) { create(:group) } + + let!(:parent_group_cluster) do + create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [parent_group]) + end + + it 'returns the project clusters followed by group clusters ordered ascending the hierarchy' do + is_expected.to eq([project_cluster, group_cluster, parent_group_cluster]) + end + end + end + + context 'for a group' do + let(:clusterable) { group } + + it 'returns the list of group clusters' do + is_expected.to eq([group_cluster]) + end + + context 'nested groups', :nested_groups do + let(:group) { create(:group, parent: parent_group) } + let(:parent_group) { create(:group) } + + let!(:parent_group_cluster) do + create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [parent_group]) + end + + it 'returns the list of group clusters ordered ascending the hierarchy' do + is_expected.to eq([group_cluster, parent_group_cluster]) + end + end + end +end |