Commit b938aa5c authored by James Lopez's avatar James Lopez

Fix and relevant spec for plan stage breaking with nil commits

parent b1b5060d
---
title: Fix cycle analytics plan stage when commits are missing
merge_request:
author:
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
event_result.map do |event| event_result.map do |event|
serialize(event) if has_permission?(event['id']) serialize(event) if has_permission?(event['id'])
end end.compact
end end
def custom_query(_base_query); end def custom_query(_base_query); end
......
...@@ -27,6 +27,8 @@ module Gitlab ...@@ -27,6 +27,8 @@ module Gitlab
end end
def first_time_reference_commit(commits, event) def first_time_reference_commit(commits, event)
return nil if commits.blank?
YAML.load(commits).find do |commit| YAML.load(commits).find do |commit|
next unless commit[:committed_date] && event['first_mentioned_in_commit_at'] next unless commit[:committed_date] && event['first_mentioned_in_commit_at']
......
...@@ -6,5 +6,13 @@ describe Gitlab::CycleAnalytics::PlanEvent do ...@@ -6,5 +6,13 @@ describe Gitlab::CycleAnalytics::PlanEvent do
it 'has the default order' do it 'has the default order' do
expect(event.order).to eq(event.start_time_attrs) expect(event.order).to eq(event.start_time_attrs)
end 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
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