Raise error when trying to create second cluster

This commit is contained in:
Matija Čupić 2017-12-03 17:33:38 +01:00
parent 7691e015d7
commit 363c57468d
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE
2 changed files with 2 additions and 2 deletions

View file

@ -5,7 +5,7 @@ module Clusters
def execute(access_token) def execute(access_token)
@access_token = access_token @access_token = access_token
return unless can_create_cluster? raise Exception.new('Instance does not support multiple clusters') unless can_create_cluster?
create_cluster.tap do |cluster| create_cluster.tap do |cluster|
ClusterProvisionWorker.perform_async(cluster.id) if cluster.persisted? ClusterProvisionWorker.perform_async(cluster.id) if cluster.persisted?

View file

@ -83,7 +83,7 @@ describe Clusters::CreateService do
it 'does not create a cluster' do it 'does not create a cluster' do
expect(ClusterProvisionWorker).not_to receive(:perform_async) expect(ClusterProvisionWorker).not_to receive(:perform_async)
expect { result }.to change { Clusters::Cluster.count }.by(0) expect { result }.to raise_error(Exception).and change { Clusters::Cluster.count }.by(0)
end end
end end
end end