summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-01 03:07:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-01 03:07:26 +0000
commit07be35d0583dcb6a7becd1401ebc8fb5b03c426b (patch)
tree1478d5da6af5d746c38fe5499a4e42c7a0a0f369
parent91939334d6085b879a3a6f212f6c2b1ec814122e (diff)
downloadgitlab-ce-07be35d0583dcb6a7becd1401ebc8fb5b03c426b.tar.gz
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--lib/gitlab/usage/docs/helper.rb4
-rw-r--r--lib/gitlab/usage/docs/templates/default.md.haml3
-rw-r--r--spec/lib/gitlab/usage/docs/helper_spec.rb79
3 files changed, 86 insertions, 0 deletions
diff --git a/lib/gitlab/usage/docs/helper.rb b/lib/gitlab/usage/docs/helper.rb
index c2e5d467dbb..bfe674b945e 100644
--- a/lib/gitlab/usage/docs/helper.rb
+++ b/lib/gitlab/usage/docs/helper.rb
@@ -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
diff --git a/lib/gitlab/usage/docs/templates/default.md.haml b/lib/gitlab/usage/docs/templates/default.md.haml
index 8911ac2ed1a..83a3a5b6698 100644
--- a/lib/gitlab/usage/docs/templates/default.md.haml
+++ b/lib/gitlab/usage/docs/templates/default.md.haml
@@ -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)
\
diff --git a/spec/lib/gitlab/usage/docs/helper_spec.rb b/spec/lib/gitlab/usage/docs/helper_spec.rb
new file mode 100644
index 00000000000..e2bb1d8d818
--- /dev/null
+++ b/spec/lib/gitlab/usage/docs/helper_spec.rb
@@ -0,0 +1,79 @@
+# 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