diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-16 03:10:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-16 03:10:02 +0300 |
commit | e7da7e417c5f09cb673b1c9aca085b53b38bbe68 (patch) | |
tree | 66a55eae14dbf527a51fac25e8c82c07571e136a /spec/lib | |
parent | be522a9abd386ad605786eeb805e12025af0c742 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_alerts_created_metric_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/usage_data_spec.rb | 4 |
2 files changed, 24 insertions, 4 deletions
diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_alerts_created_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_alerts_created_metric_spec.rb new file mode 100644 index 00000000000..85d04a6e31b --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_alerts_created_metric_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountProjectsWithAlertsCreatedMetric, feature_category: :service_ping do + before do + project = create(:project) + create(:alert_management_alert, project: project, created_at: 5.days.ago) + create(:alert_management_alert, project: project, created_at: 10.days.ago) + create(:alert_management_alert, created_at: 1.year.ago) + end + + context 'with 28d timeframe' do + let(:expected_value) { 1 } + + it_behaves_like 'a correct instrumented metric value', { time_frame: '28d' } + end + + context 'with all timeframe' do + let(:expected_value) { 2 } + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all' } + end +end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index ae3635fb5b1..1014daf693b 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -357,7 +357,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic create(:incident) create(:incident, alert_management_alert: create(:alert_management_alert)) create(:issue, alert_management_alert: create(:alert_management_alert)) - create(:alert_management_alert) create(:alert_management_http_integration, :active, project: project) end @@ -541,7 +540,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic expect(count_data[:projects_with_enabled_alert_integrations]).to eq(1) expect(count_data[:projects_with_terraform_reports]).to eq(2) expect(count_data[:projects_with_terraform_states]).to eq(2) - expect(count_data[:projects_with_alerts_created]).to eq(1) expect(count_data[:protected_branches]).to eq(2) expect(count_data[:protected_branches_except_default]).to eq(1) expect(count_data[:terraform_reports]).to eq(6) @@ -633,7 +631,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic deployment_options = { created_at: n.days.ago, project: env.project, environment: env } create(:deployment, :failed, deployment_options) create(:deployment, :success, deployment_options) - create(:alert_management_alert, project: project, created_at: n.days.ago) end for_defined_days_back do @@ -649,7 +646,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic expect(counts_monthly[:deployments]).to eq(2) expect(counts_monthly[:successful_deployments]).to eq(1) expect(counts_monthly[:failed_deployments]).to eq(1) - expect(counts_monthly[:projects_with_alerts_created]).to eq(1) expect(counts_monthly[:projects]).to eq(1) expect(counts_monthly[:packages]).to eq(1) end |