Adding custom cycle analytics stage reorders default stages

Summary

Before a custom cycle analytics stage is created, the stage table displays the list of default stages in alphabetical order. Default stages do not have an id field for ordering.

After creating a custom stage, default stages appear in the correct order (Issue, Plan, Code, Test, Review, Staging, Production).

Steps to reproduce

  1. Enable :analytics
  2. Enable :customizable_cycle_analytics
  3. View a group that has no custom stages
  4. Create a custom stage
  5. View the same group

Example Project

This happens locally

What is the current bug behavior?

Default stages are in the wrong order when there are no custom stages

What is the expected correct behavior?

Default stages should be ordered the same way before and after a custom stage is created

Relevant logs and/or screenshots

No custom stages With custom stages
Screen_Shot_2019-11-27_at_2.27.09_am Screen_Shot_2019-11-27_at_2.26.53_am

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Edited by Ezekiel Kigbo