提交 88bf3fe8 编写于 作者: T Thong Kuah

Adds cluster_for_group factory for convienence

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])
```
上级 ddf2dcf7
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册