Commit e1d5c208 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'fix-unpermitted-params-error-in-vsa' into 'master'

Fix unpermitted params error in VSA

See merge request gitlab-org/gitlab!54670
parents 3e56ac85 3ba038bc
......@@ -9,7 +9,7 @@ module Analytics
def initialize(group:, params:, current_user:, value_stream: ::Analytics::CycleAnalytics::GroupValueStream.new(group: group))
@value_stream = value_stream
@group = group
@params = process_params(params.dup)
@params = process_params(params.dup.to_h)
@current_user = current_user
end
......@@ -34,10 +34,8 @@ module Analytics
attr_reader :value_stream, :group, :params, :current_user
def process_params(raw_params)
if raw_params[:stages]
raw_params[:stages_attributes] = raw_params.delete(:stages)
raw_params[:stages_attributes].map! { |attrs| build_stage_attributes(attrs) }
end
raw_params[:stages_attributes] = raw_params.delete(:stages) || []
raw_params[:stages_attributes].map! { |attrs| build_stage_attributes(attrs) }
raw_params
end
......
......@@ -135,6 +135,17 @@ RSpec.describe Groups::Analytics::CycleAnalytics::ValueStreamsController do
expect(json_response['id']).to eq(value_stream.id)
expect(json_response['stages'].first['title']).to eq('updated stage name')
end
context 'when deleting the stage by excluding it from the stages array' do
let(:value_stream_params) { { name: 'no stages', stages: [] } }
it 'returns a successful 200 response' do
put :update, params: { id: value_stream.id, group_id: group, value_stream: value_stream_params }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['stages']).to be_empty
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