diff options
author | Małgorzata Ksionek <meksionek@gmail.com> | 2019-05-23 13:23:38 +0200 |
---|---|---|
committer | Małgorzata Ksionek <meksionek@gmail.com> | 2019-05-23 13:23:38 +0200 |
commit | ee92acccb47c073992f46f9b8f9132a8ef9a92a6 (patch) | |
tree | 691dd4c08919dc16c984fb4155c17a9c49d6c1d0 /spec | |
parent | ddb2949b1c1b0797bb982749b8af22faf9a0a421 (diff) | |
download | gitlab-ce-ee92acccb47c073992f46f9b8f9132a8ef9a92a6.tar.gz |
Add specs for median serializing
Diffstat (limited to 'spec')
-rw-r--r-- | spec/serializers/analytics_stage_serializer_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/serializers/analytics_stage_serializer_spec.rb b/spec/serializers/analytics_stage_serializer_spec.rb index dbfb3eace83..907d1b35e74 100644 --- a/spec/serializers/analytics_stage_serializer_spec.rb +++ b/spec/serializers/analytics_stage_serializer_spec.rb @@ -21,4 +21,34 @@ describe AnalyticsStageSerializer do it 'contains important elements of AnalyticsStage' do expect(subject).to include(:title, :description, :value) end + + context 'when median is equal 0' do + before do + allow_any_instance_of(Gitlab::CycleAnalytics::BaseStage).to receive(:median).and_return(0) + end + + it 'value is nil' do + expect(subject.fetch(:value)).to be_nil + end + end + + context 'when median is below 1' do + before do + allow_any_instance_of(Gitlab::CycleAnalytics::BaseStage).to receive(:median).and_return(0.12) + end + + it 'value is equal to median' do + expect(subject.fetch(:value)).to eq('less than a minute') + end + end + + context 'when median is above 1' do + before do + allow_any_instance_of(Gitlab::CycleAnalytics::BaseStage).to receive(:median).and_return(1.12) + end + + it 'value is equal to median' do + expect(subject.fetch(:value)).to eq('less than a minute') + end + end end |