summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-05-17 13:36:19 +0200
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-05-17 13:45:11 +0200
commit0385f9efc2a7844b0900958281296eb444b5070c (patch)
tree8d8c753de4a73202841574af5085fff6164b32ba
parent6a2bcb4b2ae8bed4730f3589c2693b17c57b4a75 (diff)
downloadgitlab-ce-0385f9efc2a7844b0900958281296eb444b5070c.tar.gz
Sort environments folders when opening them
Fixes gitlab-org/gitlab-ce#30814
-rw-r--r--app/controllers/projects/environments_controller.rb1
-rw-r--r--changelogs/unreleased/zj-sort-env-folders.yml4
-rw-r--r--spec/controllers/projects/environments_controller_spec.rb5
3 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index fd57afbd05f..efe83776834 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -31,6 +31,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def folder
folder_environments = project.environments.where(environment_type: params[:id])
@environments = folder_environments.with_state(params[:scope] || :available)
+ .order(:name)
respond_to do |format|
format.html
diff --git a/changelogs/unreleased/zj-sort-env-folders.yml b/changelogs/unreleased/zj-sort-env-folders.yml
new file mode 100644
index 00000000000..b3ca97aef94
--- /dev/null
+++ b/changelogs/unreleased/zj-sort-env-folders.yml
@@ -0,0 +1,4 @@
+---
+title: Sort folder for environments
+merge_request:
+author:
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb
index c0f8c36a018..e783c60452f 100644
--- a/spec/controllers/projects/environments_controller_spec.rb
+++ b/spec/controllers/projects/environments_controller_spec.rb
@@ -84,6 +84,9 @@ describe Projects::EnvironmentsController do
create(:environment, project: project,
name: 'staging-1.0/review',
state: :available)
+ create(:environment, project: project,
+ name: 'staging-1.0/preview',
+ state: :available)
end
context 'when using default format' do
@@ -107,6 +110,8 @@ describe Projects::EnvironmentsController do
expect(response).to be_ok
expect(response).not_to render_template 'folder'
expect(json_response['environments'][0])
+ .to include('name' => 'staging-1.0/preview')
+ expect(json_response['environments'][1])
.to include('name' => 'staging-1.0/review')
end
end