Commit d6459449 authored by Adam Hegyi's avatar Adam Hegyi

Fix updating VSA stage

This change fixes a bug where the value stream stage records were
updated and deleted using accepts_nested_attributes_for.
parent bb13a881
......@@ -26,7 +26,7 @@ module Analytics
def to_be_deleted?(processed_params, stage_id)
processed_params.has_key?(:stages_attributes) &&
processed_params[:stages_attributes].none? { |attrs| Integer(attrs[:id]) == stage_id }
processed_params[:stages_attributes].none? { |attrs| attrs[:id] && Integer(attrs[:id]) == stage_id }
end
def success_http_status
......
......@@ -101,5 +101,24 @@ RSpec.describe Analytics::CycleAnalytics::ValueStreams::UpdateService do
expect(subject.payload[:value_stream].stages.last.name).to eq('plan')
end
end
context 'when removing a stage and adding a new stage' do
let(:params) do
{
name: 'VS 1',
stages: [
{ id: first_stage.id, name: first_stage.name, custom: true },
{ name: 'new stage', custom: true, start_event_identifier: 'merge_request_created', end_event_identifier: 'merge_request_closed' }
]
}
end
it 'creates the stage' do
expect(subject).to be_success
current_stage_names = subject.payload[:value_stream].stages.map(&:name)
expect(current_stage_names).to match_array([first_stage.name, 'new stage'])
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