diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-07-17 11:32:04 +1200 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-07-19 09:53:56 +1200 |
commit | 88bf3fe8b4c07d38b331fc1d72487ba2b351395c (patch) | |
tree | 7d0b4859ac72f10b35078c9faa648773b27942bd | |
parent | ddf2dcf7fdad69135cee590307773b255d2fe0b5 (diff) | |
download | gitlab-ce-group_with_cluster_factory.tar.gz |
Adds cluster_for_group factory for convienencegroup_with_cluster_factory
Also means we don't have to resort to an update statement to set parent
for child groups who also have clusters.
This is much shorter than
```
create(:cluster, :provided_by_gcp, :group, groups: [group])
```
-rw-r--r-- | spec/factories/clusters/clusters.rb | 2 | ||||
-rw-r--r-- | spec/models/concerns/deployment_platform_spec.rb | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb index ab332fc238b..171f5256d2b 100644 --- a/spec/factories/clusters/clusters.rb +++ b/spec/factories/clusters/clusters.rb @@ -5,6 +5,8 @@ FactoryBot.define do cluster_type :project_type managed true + factory :cluster_for_group, traits: [:provided_by_gcp, :group] + trait :instance do cluster_type { Clusters::Cluster.cluster_types[:instance_type] } end diff --git a/spec/models/concerns/deployment_platform_spec.rb b/spec/models/concerns/deployment_platform_spec.rb index 2378f400540..c4f9f62ece5 100644 --- a/spec/models/concerns/deployment_platform_spec.rb +++ b/spec/models/concerns/deployment_platform_spec.rb @@ -46,12 +46,11 @@ describe DeploymentPlatform do end context 'when child group has configured kubernetes cluster', :nested_groups do - let!(:child_group1_cluster) { create(:cluster, :provided_by_gcp, :group) } - let(:child_group1) { child_group1_cluster.group } + let(:child_group1) { create(:group, parent: group) } + let!(:child_group1_cluster) { create(:cluster_for_group, groups: [child_group1]) } before do project.update!(group: child_group1) - child_group1.update!(parent: group) end it 'returns the Kubernetes platform for the child group' do @@ -59,11 +58,10 @@ describe DeploymentPlatform do end context 'deeply nested group' do - let!(:child_group2_cluster) { create(:cluster, :provided_by_gcp, :group) } - let(:child_group2) { child_group2_cluster.group } + let(:child_group2) { create(:group, parent: child_group1) } + let!(:child_group2_cluster) { create(:cluster_for_group, groups: [child_group2]) } before do - child_group2.update!(parent: child_group1) project.update!(group: child_group2) end |