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 ...@@ -5,7 +5,7 @@ module Gitlab
class MetricDefinition class MetricDefinition
METRIC_SCHEMA_PATH = Rails.root.join('config', 'metrics', 'schema.json') METRIC_SCHEMA_PATH = Rails.root.join('config', 'metrics', 'schema.json')
BASE_REPO_PATH = 'https://gitlab.com/gitlab-org/gitlab/-/blob/master' 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 :path
attr_reader :attributes attr_reader :attributes
...@@ -107,7 +107,7 @@ module Gitlab ...@@ -107,7 +107,7 @@ module Gitlab
end end
def skip_validation? 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 end
end end
......
...@@ -87,26 +87,21 @@ RSpec.describe Gitlab::Usage::MetricDefinition do ...@@ -87,26 +87,21 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
describe 'statuses' do describe 'statuses' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:status, :raise_exception) do where(:status, :skip_validation?) do
'deprecated' | false 'deprecated' | true
'removed' | false 'removed' | true
'data_available' | false 'data_available' | false
'random' | true 'implemented' | false
'not_used' | false
end end
with_them do with_them do
subject(:validation) 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 end
it "checks for valid/invalid statuses" do it 'returns true/false for skip_validation' do
if raise_exception expect(validation).to eq(skip_validation?)
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
end end
end 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