Commit 6afd1e5a authored by David Kim's avatar David Kim

Merge branch '334300-update-dictionary-renderer' into 'master'

Update dictionary renderer to include data category

See merge request gitlab-org/gitlab!64641
parents de4af4d2 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
......
......@@ -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)
\
......
# 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
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