Commit 982cb911 authored by Phil Hughes's avatar Phil Hughes

Merge branch '212647-fix-duplicated-events-on-stage-form' into 'master'

Fix duplicated events on VSM stage form

Closes #212647

See merge request gitlab-org/gitlab!29030
parents 64dc307a ef578bbd
......@@ -11,7 +11,11 @@ module Analytics
private
def events
Gitlab::Analytics::CycleAnalytics::StageEvents.events.sort_by(&:name)
(stage_events.events - stage_events.internal_events).sort_by(&:name)
end
def stage_events
Gitlab::Analytics::CycleAnalytics::StageEvents
end
end
end
......
......@@ -20,11 +20,17 @@ module Analytics
end
def allowed_end_events
pairing_rules.fetch(object, []).map(&:identifier)
pairing_rules.fetch(object, []).map do |event|
event.identifier unless stage_events.internal_events.include?(event)
end.compact
end
def pairing_rules
Gitlab::Analytics::CycleAnalytics::StageEvents.pairing_rules
stage_events.pairing_rules
end
def stage_events
Gitlab::Analytics::CycleAnalytics::StageEvents
end
end
end
......
---
title: Fix duplicated events on Value Stream Analytics stage form
merge_request: 29030
author:
type: fixed
......@@ -133,7 +133,7 @@ module EE
override :events
def events
strong_memoize(:events) do
super + EE_EVENTS
(super + EE_EVENTS).uniq
end
end
......
......@@ -34,13 +34,15 @@ describe Analytics::CycleAnalytics::StagesController do
expect(response_start_events).to eq(start_events)
end
it 'returns correct event names' do
it 'does not include internal events' do
subject
response_event_names = json_response['events'].map { |s| s['name'] }
event_names = Gitlab::Analytics::CycleAnalytics::StageEvents.events.map(&:name)
event_names = Gitlab::Analytics::CycleAnalytics::StageEvents.events
internal_events = Gitlab::Analytics::CycleAnalytics::StageEvents.internal_events
expected_event_names = (event_names - internal_events).map(&:name)
expect(response_event_names).to eq(event_names.sort)
expect(response_event_names).to eq(expected_event_names.sort)
end
it 'succeeds for subgroups' do
......
......@@ -34,13 +34,15 @@ describe Groups::Analytics::CycleAnalytics::StagesController do
expect(response_start_events).to eq(start_events)
end
it 'returns correct event names' do
it 'does not include internal events' do
subject
response_event_names = json_response['events'].map { |s| s['name'] }
event_names = Gitlab::Analytics::CycleAnalytics::StageEvents.events.map(&:name).sort
event_names = Gitlab::Analytics::CycleAnalytics::StageEvents.events
internal_events = Gitlab::Analytics::CycleAnalytics::StageEvents.internal_events
expected_event_names = (event_names - internal_events).map(&:name)
expect(response_event_names).to eq(event_names)
expect(response_event_names).to eq(expected_event_names.sort)
end
it 'succeeds for subgroups' do
......
......@@ -306,7 +306,7 @@ describe('CustomStageForm', () => {
expect(stopOptions.at(0).html()).toEqual('<option value="">Select stop event</option>');
selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex - 1);
selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex);
return Vue.nextTick().then(() => {
stopOptions = wrapper.find(sel.endEvent);
......
......@@ -24,6 +24,13 @@ module Gitlab
EVENTS = ENUM_MAPPING.keys.freeze
INTERNAL_EVENTS = [
StageEvents::CodeStageStart,
StageEvents::IssueStageEnd,
StageEvents::PlanStageStart,
StageEvents::ProductionStageEnd
].freeze
# Defines which start_event and end_event pairs are allowed
PAIRING_RULES = {
StageEvents::PlanStageStart => [
......@@ -67,6 +74,11 @@ module Gitlab
def self.enum_mapping
ENUM_MAPPING
end
# Events that are specific to the 7 default stages
def self.internal_events
INTERNAL_EVENTS
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