Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
af8c304a
Commit
af8c304a
authored
Apr 06, 2021
by
Alper Akgun
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'skip-metric-follow-up' into 'master'
Skip metric follow up See merge request gitlab-org/gitlab!58625
parents
6f786c24
d5c69035
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
15 deletions
+10
-15
lib/gitlab/usage/metric_definition.rb
lib/gitlab/usage/metric_definition.rb
+2
-2
spec/lib/gitlab/usage/metric_definition_spec.rb
spec/lib/gitlab/usage/metric_definition_spec.rb
+8
-13
No files found.
lib/gitlab/usage/metric_definition.rb
View file @
af8c304a
...
...
@@ -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
...
...
spec/lib/gitlab/usage/metric_definition_spec.rb
View file @
af8c304a
...
...
@@ -87,26 +87,21 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
describe
'statuses'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:status
,
:
raise_exception
)
do
'deprecated'
|
fals
e
'removed'
|
fals
e
where
(
:status
,
:
skip_validation?
)
do
'deprecated'
|
tru
e
'removed'
|
tru
e
'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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment