Commit 0c342a8c authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '196698-vsm-ensure-relative-position-is-set' into 'master'

Ensure VSM stage has relative position

See merge request gitlab-org/gitlab!27801
parents 38703248 63687c9e
......@@ -56,6 +56,9 @@ module Analytics
# rubocop: enable CodeReuse/ActiveRecord
def handle_position_change
# make sure that unpositioned items have relative_position
@stage.class.move_nulls_to_end(parent.cycle_analytics_stages.ordered)
move_before_id = params.delete(:move_before_id)
move_after_id = params.delete(:move_after_id)
......
......@@ -119,6 +119,22 @@ describe Analytics::CycleAnalytics::Stages::UpdateService do
let!(:middle_stage) { create(:cycle_analytics_group_stage, group: group, relative_position: 11) }
let!(:last_stage) { create(:cycle_analytics_group_stage, group: group, relative_position: 12) }
context 'when there are stages without position' do
let!(:unpositioned_stage1) { create(:cycle_analytics_group_stage, group: group) }
let!(:unpositioned_stage2) { create(:cycle_analytics_group_stage, group: group) }
before do
params[:id] = first_stage.id
params[:move_after_id] = unpositioned_stage2.id
end
it 'when moving the stage down' do
subject
expect(persisted_stages.last(3)).to eq([unpositioned_stage1, unpositioned_stage2, first_stage])
end
end
context 'when moving the stage down' do
before do
params[:id] = first_stage.id
......
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