Fix and relevant spec for plan stage breaking with nil commits
This commit is contained in:
parent
b1b5060dba
commit
b938aa5cc8
4 changed files with 15 additions and 1 deletions
4
changelogs/unreleased/fix-cycle-analytics-plan-issue.yml
Normal file
4
changelogs/unreleased/fix-cycle-analytics-plan-issue.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix cycle analytics plan stage when commits are missing
|
||||
merge_request:
|
||||
author:
|
|
@ -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
|
||||
|
|
|
@ -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']
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue