From 9c49fa2d92a3ab1051df87e4d75d9802a1b7cfc7 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 24 Nov 2016 12:38:54 +0100 Subject: fix for builds with no start date and spec --- spec/serializers/analytics_build_entity_spec.rb | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'spec/serializers') diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb index c0b7e86b17c..ba562353661 100644 --- a/spec/serializers/analytics_build_entity_spec.rb +++ b/spec/serializers/analytics_build_entity_spec.rb @@ -7,7 +7,9 @@ describe AnalyticsBuildEntity do context 'build with an author' do let(:user) { create(:user) } - let(:build) { create(:ci_build, author: user, started_at: 2.hours.ago, finished_at: 1.hour.ago) } + let(:started_at) { 2.hours.ago } + let(:finished_at) { 1.hour.ago } + let(:build) { create(:ci_build, author: user, started_at: started_at, finished_at: finished_at) } subject { entity.as_json } @@ -31,5 +33,32 @@ describe AnalyticsBuildEntity do it 'contains the duration' do expect(subject[:total_time]).to eq(hours: 1 ) end + + context 'no started at or finished at date' do + let(:started_at) { nil } + let(:finished_at) { nil } + + it 'does not blow up' do + expect{ subject[:date] }.not_to raise_error + end + + it '' + end + + context 'no started at date' do + let(:started_at) { nil } + + it 'does not blow up' do + expect{ subject[:date] }.not_to raise_error + end + end + + context 'no finished at date' do + let(:finished_at) { nil } + + it 'does not blow up' do + expect{ subject[:date] }.not_to raise_error + end + end end end -- cgit v1.2.3 From 830f739b99b36f8862dadc524e4aa72ec5a3366e Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 25 Nov 2016 11:22:44 +0100 Subject: use an empty total time when the build has not started yet so the UI knows --- spec/serializers/analytics_build_entity_spec.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'spec/serializers') diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb index ba562353661..1a9ad1968bd 100644 --- a/spec/serializers/analytics_build_entity_spec.rb +++ b/spec/serializers/analytics_build_entity_spec.rb @@ -42,7 +42,13 @@ describe AnalyticsBuildEntity do expect{ subject[:date] }.not_to raise_error end - it '' + it 'shows the right message' do + expect(subject[:date]).to eq('Not started') + end + + it 'shows the right total time' do + expect(subject[:total_time]).to eq({}) + end end context 'no started at date' do @@ -51,6 +57,14 @@ describe AnalyticsBuildEntity do it 'does not blow up' do expect{ subject[:date] }.not_to raise_error end + + it 'shows the right message' do + expect(subject[:date]).to eq('Not started') + end + + it 'shows the right total time' do + expect(subject[:total_time]).to eq({}) + end end context 'no finished at date' do @@ -59,6 +73,14 @@ describe AnalyticsBuildEntity do it 'does not blow up' do expect{ subject[:date] }.not_to raise_error end + + it 'shows the right message' do + expect(subject[:date]).to eq('about 2 hours ago') + end + + it 'shows the right total time' do + expect(subject[:total_time]).to eq({hours: 2}) + end end end end -- cgit v1.2.3 From 94a74e79cb087cc499add60ab638d999bc7e3815 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 25 Nov 2016 11:46:13 +0100 Subject: fix rubocop warning --- spec/serializers/analytics_build_entity_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/serializers') diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb index 1a9ad1968bd..6b33fe66a63 100644 --- a/spec/serializers/analytics_build_entity_spec.rb +++ b/spec/serializers/analytics_build_entity_spec.rb @@ -79,7 +79,7 @@ describe AnalyticsBuildEntity do end it 'shows the right total time' do - expect(subject[:total_time]).to eq({hours: 2}) + expect(subject[:total_time]).to eq({ hours: 2 }) end end end -- cgit v1.2.3 From 651eccda62218532b24ff75384c943256bf70224 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 29 Nov 2016 11:57:16 +0100 Subject: Expose timestamp in build entity used by serializer --- spec/serializers/build_entity_spec.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'spec/serializers') diff --git a/spec/serializers/build_entity_spec.rb b/spec/serializers/build_entity_spec.rb index 6dcfaec259e..60c9642ee2c 100644 --- a/spec/serializers/build_entity_spec.rb +++ b/spec/serializers/build_entity_spec.rb @@ -1,23 +1,30 @@ require 'spec_helper' describe BuildEntity do + let(:build) { create(:ci_build) } + let(:entity) do described_class.new(build, request: double) end subject { entity.as_json } - context 'when build is a regular job' do - let(:build) { create(:ci_build) } + it 'contains paths to build page and retry action' do + expect(subject).to include(:build_path, :retry_path) + end - it 'contains paths to build page and retry action' do - expect(subject).to include(:build_path, :retry_path) - expect(subject).not_to include(:play_path) - end + it 'does not contain sensitive information' do + expect(subject).not_to include(/token/) + expect(subject).not_to include(/variables/) + end + + it 'contains timestamps' do + expect(subject).to include(:created_at, :updated_at) + end - it 'does not contain sensitive information' do - expect(subject).not_to include(/token/) - expect(subject).not_to include(/variables/) + context 'when build is a regular job' do + it 'does not contain path to play action' do + expect(subject).not_to include(:play_path) end end -- cgit v1.2.3