Fix and relevant spec for plan stage breaking with nil commits

This commit is contained in:
James Lopez 2016-11-23 09:10:04 +01:00
parent b1b5060dba
commit b938aa5cc8
4 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,4 @@
---
title: Fix cycle analytics plan stage when commits are missing
merge_request:
author:

View file

@ -16,7 +16,7 @@ module Gitlab
event_result.map do |event|
serialize(event) if has_permission?(event['id'])
end
end.compact
end
def custom_query(_base_query); end

View file

@ -27,6 +27,8 @@ module Gitlab
end
def first_time_reference_commit(commits, event)
return nil if commits.blank?
YAML.load(commits).find do |commit|
next unless commit[:committed_date] && event['first_mentioned_in_commit_at']

View file

@ -6,5 +6,13 @@ describe Gitlab::CycleAnalytics::PlanEvent do
it 'has the default order' do
expect(event.order).to eq(event.start_time_attrs)
end
context 'no commits' do
it 'does not blow up if there are no commits' do
allow_any_instance_of(Gitlab::CycleAnalytics::EventsQuery).to receive(:execute).and_return([{}])
expect { event.fetch }.not_to raise_error
end
end
end
end