diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/lib/gitlab/usage/metric_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/usage/metric_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage/metric_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage/metric_spec.rb b/spec/lib/gitlab/usage/metric_spec.rb index 19d2d3048eb..10ae94e746b 100644 --- a/spec/lib/gitlab/usage/metric_spec.rb +++ b/spec/lib/gitlab/usage/metric_spec.rb @@ -51,4 +51,31 @@ RSpec.describe Gitlab::Usage::Metric do expect(described_class.new(issue_count_metric_definiton).with_suggested_name).to eq({ counts: { issues: 'count_issues' } }) end end + + context 'unavailable metric' do + let(:instrumentation_class) { "UnavailableMetric" } + let(:issue_count_metric_definiton) do + double(:issue_count_metric_definiton, + attributes.merge({ attributes: attributes, instrumentation_class: instrumentation_class }) + ) + end + + before do + unavailable_metric_class = Class.new(Gitlab::Usage::Metrics::Instrumentations::CountIssuesMetric) do + def available? + false + end + end + + stub_const("Gitlab::Usage::Metrics::Instrumentations::#{instrumentation_class}", unavailable_metric_class) + end + + [:with_value, :with_instrumentation, :with_suggested_name].each do |method_name| + describe "##{method_name}" do + it 'returns an empty hash' do + expect(described_class.new(issue_count_metric_definiton).public_send(method_name)).to eq({}) + end + end + end + end end |