diff options
Diffstat (limited to 'spec/services/alert_management/http_integrations/create_service_spec.rb')
-rw-r--r-- | spec/services/alert_management/http_integrations/create_service_spec.rb | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/spec/services/alert_management/http_integrations/create_service_spec.rb b/spec/services/alert_management/http_integrations/create_service_spec.rb index 5200ec27dd1..bced09044eb 100644 --- a/spec/services/alert_management/http_integrations/create_service_spec.rb +++ b/spec/services/alert_management/http_integrations/create_service_spec.rb @@ -38,12 +38,6 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService, feature_categor it_behaves_like 'error response', 'You have insufficient permissions to create an HTTP integration for this project' end - context 'when an integration already exists' do - let_it_be(:existing_integration) { create(:alert_management_http_integration, project: project) } - - it_behaves_like 'error response', 'Multiple HTTP integrations are not supported for this project' - end - context 'when an error occurs during update' do it_behaves_like 'error response', "Name can't be blank" end @@ -61,6 +55,38 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService, feature_categor expect(integration.token).to be_present expect(integration.endpoint_identifier).to be_present end + + context 'with an existing HTTP integration' do + let_it_be(:http_integration) { create(:alert_management_http_integration, project: project) } + + it_behaves_like 'error response', 'Multiple integrations of a single type are not supported for this project' + + context 'when creating a different type of integration' do + let(:params) { { type_identifier: :prometheus, name: 'Prometheus' } } + + it 'is successful' do + expect(response).to be_success + expect(response.payload[:integration]).to be_a(::AlertManagement::HttpIntegration) + end + end + end + + context 'with an existing Prometheus integration' do + let_it_be(:http_integration) { create(:alert_management_prometheus_integration, project: project) } + + context 'when creating a different type of integration' do + it 'is successful' do + expect(response).to be_success + expect(response.payload[:integration]).to be_a(::AlertManagement::HttpIntegration) + end + end + + context 'when creating the same time of integration' do + let(:params) { { type_identifier: :prometheus, name: 'Prometheus' } } + + it_behaves_like 'error response', 'Multiple integrations of a single type are not supported for this project' + end + end end end end |