Commit af8c304a authored by Alper Akgun's avatar Alper Akgun

Merge branch 'skip-metric-follow-up' into 'master'

Skip metric follow up

See merge request gitlab-org/gitlab!58625
parents 6f786c24 d5c69035
......@@ -5,7 +5,7 @@ module Gitlab
class MetricDefinition
METRIC_SCHEMA_PATH = Rails.root.join('config', 'metrics', 'schema.json')
BASE_REPO_PATH = 'https://gitlab.com/gitlab-org/gitlab/-/blob/master'
DEPRECATED_METRIC_STATUSES = %w[deprecated removed].to_set.freeze
SKIP_VALIDATION_STATUSES = %w[deprecated removed].to_set.freeze
attr_reader :path
attr_reader :attributes
......@@ -107,7 +107,7 @@ module Gitlab
end
def skip_validation?
!!attributes[:skip_validation] || @skip_validation || DEPRECATED_METRIC_STATUSES.include?(attributes[:status])
!!attributes[:skip_validation] || @skip_validation || SKIP_VALIDATION_STATUSES.include?(attributes[:status])
end
end
end
......
......@@ -87,26 +87,21 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
describe 'statuses' do
using RSpec::Parameterized::TableSyntax
where(:status, :raise_exception) do
'deprecated' | false
'removed' | false
where(:status, :skip_validation?) do
'deprecated' | true
'removed' | true
'data_available' | false
'random' | true
'implemented' | false
'not_used' | false
end
with_them do
subject(:validation) do
described_class.new(path, attributes.merge( { status: status } )).validate!
described_class.new(path, attributes.merge( { status: status } )).send(:skip_validation?)
end
it "checks for valid/invalid statuses" do
if raise_exception
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception).at_least(:once).with(instance_of(Gitlab::Usage::Metric::InvalidMetricError))
else
expect(Gitlab::ErrorTracking).not_to receive(:track_and_raise_for_dev_exception)
end
validation
it 'returns true/false for skip_validation' do
expect(validation).to eq(skip_validation?)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment