Commit 18071fe1 authored by James Lopez's avatar James Lopez

Merge branch 'ag-add-unit-to-analytics-summary-entity' into 'master'

Expose optional unit in Analytics Summary Entity

See merge request gitlab-org/gitlab!28777
parents d13ed9eb 3530f6de
......@@ -3,4 +3,5 @@
class AnalyticsSummaryEntity < Grape::Entity
expose :value, safe: true
expose :title
expose :unit, if: { with_unit: true }
end
......@@ -28,4 +28,18 @@ describe AnalyticsSummarySerializer do
it 'contains important elements of AnalyticsStage' do
expect(subject).to include(:title, :value)
end
it 'does not include unit' do
expect(subject).not_to include(:unit)
end
context 'when representing with unit' do
let(:resource) { { title: 'frequency', value: 1.12, unit: 'per day' } }
subject { described_class.new.represent(resource, with_unit: true) }
it 'contains unit' do
expect(subject).to include(:unit)
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