Commit 3530f6de authored by Aakriti Gupta's avatar Aakriti Gupta Committed by James Lopez

Expose optional unit in Analytics Summary Entity

parent bf0e704f
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
class AnalyticsSummaryEntity < Grape::Entity class AnalyticsSummaryEntity < Grape::Entity
expose :value, safe: true expose :value, safe: true
expose :title expose :title
expose :unit, if: { with_unit: true }
end end
...@@ -28,4 +28,18 @@ describe AnalyticsSummarySerializer do ...@@ -28,4 +28,18 @@ describe AnalyticsSummarySerializer do
it 'contains important elements of AnalyticsStage' do it 'contains important elements of AnalyticsStage' do
expect(subject).to include(:title, :value) expect(subject).to include(:title, :value)
end 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 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