diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/finders/alert_management | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/finders/alert_management')
-rw-r--r-- | spec/finders/alert_management/http_integrations_finder_spec.rb | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/finders/alert_management/http_integrations_finder_spec.rb b/spec/finders/alert_management/http_integrations_finder_spec.rb new file mode 100644 index 00000000000..d65de2cdbbd --- /dev/null +++ b/spec/finders/alert_management/http_integrations_finder_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe AlertManagement::HttpIntegrationsFinder do + let_it_be(:project) { create(:project) } + let_it_be_with_reload(:integration) { create(:alert_management_http_integration, project: project ) } + let_it_be(:extra_integration) { create(:alert_management_http_integration, project: project ) } + let_it_be(:alt_project_integration) { create(:alert_management_http_integration) } + + let(:params) { {} } + + describe '#execute' do + subject(:execute) { described_class.new(project, params).execute } + + context 'empty params' do + it { is_expected.to contain_exactly(integration) } + end + + context 'endpoint_identifier param given' do + let(:params) { { endpoint_identifier: integration.endpoint_identifier } } + + it { is_expected.to contain_exactly(integration) } + + context 'matches an unavailable integration' do + let(:params) { { endpoint_identifier: extra_integration.endpoint_identifier } } + + it { is_expected.to be_empty } + end + + context 'but unknown' do + let(:params) { { endpoint_identifier: 'unknown' } } + + it { is_expected.to be_empty } + end + + context 'but blank' do + let(:params) { { endpoint_identifier: nil } } + + it { is_expected.to contain_exactly(integration) } + end + end + + context 'active param given' do + let(:params) { { active: true } } + + it { is_expected.to contain_exactly(integration) } + + context 'when integration is disabled' do + before do + integration.update!(active: false) + end + + it { is_expected.to be_empty } + end + + context 'but blank' do + let(:params) { { active: nil } } + + it { is_expected.to contain_exactly(integration) } + end + end + + context 'project has no integrations' do + subject(:execute) { described_class.new(create(:project), params).execute } + + it { is_expected.to be_empty } + end + end +end |