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
b4559327
Commit
b4559327
authored
Jun 22, 2021
by
Luis Mejia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dictionary renderer to include data category
Changelog: changed
parent
5d44287e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
0 deletions
+86
-0
lib/gitlab/usage/docs/helper.rb
lib/gitlab/usage/docs/helper.rb
+4
-0
lib/gitlab/usage/docs/templates/default.md.haml
lib/gitlab/usage/docs/templates/default.md.haml
+3
-0
spec/lib/gitlab/usage/docs/helper_spec.rb
spec/lib/gitlab/usage/docs/helper_spec.rb
+79
-0
No files found.
lib/gitlab/usage/docs/helper.rb
View file @
b4559327
...
...
@@ -51,6 +51,10 @@ module Gitlab
"Tiers:
#{
format
(
:tier
,
object
[
:tier
])
}
"
end
def
render_data_category
(
object
)
"Data Category: `
#{
object
[
:data_category
]
}
`"
end
def
format
(
key
,
value
)
Gitlab
::
Usage
::
Docs
::
ValueFormatter
.
format
(
key
,
value
)
end
...
...
lib/gitlab/usage/docs/templates/default.md.haml
View file @
b4559327
...
...
@@ -38,6 +38,9 @@
=
render_yaml_link
(
object
.
yaml_path
)
\
=
render_owner
(
object
.
attributes
)
-
if
object
.
attributes
[
:data_category
].
present?
\
=
render_data_category
(
object
.
attributes
)
\
=
render_status
(
object
.
attributes
)
\
...
...
spec/lib/gitlab/usage/docs/helper_spec.rb
0 → 100644
View file @
b4559327
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Usage
::
Docs
::
Helper
do
subject
(
:helper
)
{
klass
.
new
}
let_it_be
(
:klass
)
do
Class
.
new
do
include
Gitlab
::
Usage
::
Docs
::
Helper
end
end
let
(
:metric_definition
)
do
{
data_category:
'Standard'
,
name:
'test_metric'
,
description:
description
,
product_group:
'group::product intelligence'
,
status:
'data_available'
,
tier:
%w(free premium)
}
end
let
(
:description
)
{
'Metric description'
}
describe
'#render_name'
do
it
{
expect
(
helper
.
render_name
(
metric_definition
[
:name
])).
to
eq
(
'### `test_metric`'
)
}
end
describe
'#render_description'
do
context
'without description'
do
let
(
:description
)
{
nil
}
it
{
expect
(
helper
.
render_description
(
metric_definition
)).
to
eq
(
'Missing description'
)
}
end
context
'without description'
do
it
{
expect
(
helper
.
render_description
(
metric_definition
)).
to
eq
(
'Metric description'
)
}
end
end
describe
'#render_yaml_link'
do
let
(
:yaml_link
)
{
'config/metrics/license/test_metric.yml'
}
let
(
:expected
)
{
"[YAML definition](
#{
yaml_link
}
)"
}
it
{
expect
(
helper
.
render_yaml_link
(
yaml_link
)).
to
eq
(
expected
)
}
end
describe
'#render_status'
do
let
(
:expected
)
{
"Status: `data_available`"
}
it
{
expect
(
helper
.
render_status
(
metric_definition
)).
to
eq
(
expected
)
}
end
describe
'#render_owner'
do
let
(
:expected
)
{
"Group: `group::product intelligence`"
}
it
{
expect
(
helper
.
render_owner
(
metric_definition
)).
to
eq
(
expected
)
}
end
describe
'#render_tiers'
do
let
(
:expected
)
{
"Tiers: `free`, `premium`"
}
it
{
expect
(
helper
.
render_tiers
(
metric_definition
)).
to
eq
(
expected
)
}
end
describe
'#render_data_category'
do
let
(
:expected
)
{
'Data Category: `Standard`'
}
it
{
expect
(
helper
.
render_data_category
(
metric_definition
)).
to
eq
(
expected
)
}
end
describe
'#render_owner'
do
let
(
:expected
)
{
"Group: `group::product intelligence`"
}
it
{
expect
(
helper
.
render_owner
(
metric_definition
)).
to
eq
(
expected
)
}
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