Check behaviour when adding more than one cluster

This commit is contained in:
Matija Čupić 2017-11-18 20:18:48 +01:00
parent 1a9cef7962
commit afcfe182a6
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE

View file

@ -7,6 +7,7 @@ describe Clusters::CreateService do
let(:result) { described_class.new(project, user, params).execute(access_token) }
context 'when provider is gcp' do
context 'when project has no clusters' do
context 'when correct params' do
let(:params) do
{
@ -61,4 +62,29 @@ describe Clusters::CreateService do
end
end
end
context 'when project has a cluster' do
let(:params) do
{
name: 'test-cluster',
provider_type: :gcp,
provider_gcp_attributes: {
gcp_project_id: 'gcp-project',
zone: 'us-central1-a',
num_nodes: 1,
machine_type: 'machine_type-a'
}
}
end
before do
Clusters::Cluster.create(params.merge(user: user, projects: [project]))
end
it 'does not create a cluster' do
expect(ClusterProvisionWorker).not_to receive(:perform_async)
expect { result }.to change { Clusters::Cluster.count }.by(0)
end
end
end
end