GitLab steht Mittwoch, den 23. September, zwischen 10:00 und 12:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit 9c49fa2d authored by James Lopez's avatar James Lopez

fix for builds with no start date and spec

parent afe90d52
......@@ -2,6 +2,8 @@ module EntityDateHelper
include ActionView::Helpers::DateHelper
def interval_in_words(diff)
return 'not started' unless diff
"#{distance_of_time_in_words(Time.now, diff)} ago"
end
......
......@@ -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
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