diff options
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/clusters/applications/create_service_spec.rb | 42 | ||||
-rw-r--r-- | spec/services/clusters/update_service_spec.rb | 27 |
2 files changed, 61 insertions, 8 deletions
diff --git a/spec/services/clusters/applications/create_service_spec.rb b/spec/services/clusters/applications/create_service_spec.rb index a9985133b93..0bd7719345e 100644 --- a/spec/services/clusters/applications/create_service_spec.rb +++ b/spec/services/clusters/applications/create_service_spec.rb @@ -60,14 +60,6 @@ describe Clusters::Applications::CreateService do end end - context 'invalid application' do - let(:params) { { application: 'non-existent' } } - - it 'raises an error' do - expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError) - end - end - context 'knative application' do let(:params) do { @@ -100,5 +92,39 @@ describe Clusters::Applications::CreateService do expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError) end end + + context 'group cluster' do + let(:cluster) { create(:cluster, :provided_by_gcp, :group) } + + using RSpec::Parameterized::TableSyntax + + before do + allow_any_instance_of(Clusters::Applications::ScheduleInstallationService).to receive(:execute) + end + + where(:application, :association, :allowed) do + 'helm' | :application_helm | true + 'ingress' | :application_ingress | true + 'runner' | :application_runner | false + 'jupyter' | :application_jupyter | false + 'prometheus' | :application_prometheus | false + end + + with_them do + let(:params) { { application: application } } + + it 'executes for each application' do + if allowed + expect do + subject + + cluster.reload + end.to change(cluster, association) + else + expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError) + end + end + end + end end end diff --git a/spec/services/clusters/update_service_spec.rb b/spec/services/clusters/update_service_spec.rb index a1b20c61116..73f9be242a3 100644 --- a/spec/services/clusters/update_service_spec.rb +++ b/spec/services/clusters/update_service_spec.rb @@ -62,5 +62,32 @@ describe Clusters::UpdateService do expect(cluster.errors[:"platform_kubernetes.namespace"]).to be_present end end + + context 'when cluster is provided by GCP' do + let(:cluster) { create(:cluster, :project, :provided_by_gcp) } + + let(:params) do + { + name: 'my-new-name' + } + end + + it 'does not change cluster name' do + is_expected.to eq(false) + + cluster.reload + expect(cluster.name).to eq('test-cluster') + end + + context 'when cluster is being created' do + let(:cluster) { create(:cluster, :providing_by_gcp) } + + it 'rejects changes' do + is_expected.to eq(false) + + expect(cluster.errors.full_messages).to include('cannot modify during creation') + end + end + end end end |