Merge branch 'group_with_cluster_factory' into 'master'

Adds cluster_for_group factory for convenience

See merge request gitlab-org/gitlab-ce!30826
This commit is contained in:
Robert Speicher 2019-07-22 20:36:50 +00:00
commit 6c04066d45
2 changed files with 6 additions and 6 deletions

View file

@ -5,6 +5,8 @@ FactoryBot.define do
cluster_type :project_type cluster_type :project_type
managed true managed true
factory :cluster_for_group, traits: [:provided_by_gcp, :group]
trait :instance do trait :instance do
cluster_type { Clusters::Cluster.cluster_types[:instance_type] } cluster_type { Clusters::Cluster.cluster_types[:instance_type] }
end end

View file

@ -46,12 +46,11 @@ describe DeploymentPlatform do
end end
context 'when child group has configured kubernetes cluster', :nested_groups do context 'when child group has configured kubernetes cluster', :nested_groups do
let!(:child_group1_cluster) { create(:cluster, :provided_by_gcp, :group) } let(:child_group1) { create(:group, parent: group) }
let(:child_group1) { child_group1_cluster.group } let!(:child_group1_cluster) { create(:cluster_for_group, groups: [child_group1]) }
before do before do
project.update!(group: child_group1) project.update!(group: child_group1)
child_group1.update!(parent: group)
end end
it 'returns the Kubernetes platform for the child group' do it 'returns the Kubernetes platform for the child group' do
@ -59,11 +58,10 @@ describe DeploymentPlatform do
end end
context 'deeply nested group' do context 'deeply nested group' do
let!(:child_group2_cluster) { create(:cluster, :provided_by_gcp, :group) } let(:child_group2) { create(:group, parent: child_group1) }
let(:child_group2) { child_group2_cluster.group } let!(:child_group2_cluster) { create(:cluster_for_group, groups: [child_group2]) }
before do before do
child_group2.update!(parent: child_group1)
project.update!(group: child_group2) project.update!(group: child_group2)
end end