Commit 0385f9ef authored by Z.J. van de Weg's avatar Z.J. van de Weg

Sort environments folders when opening them

Fixes gitlab-org/gitlab-ce#30814
parent 6a2bcb4b
...@@ -31,6 +31,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -31,6 +31,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def folder def folder
folder_environments = project.environments.where(environment_type: params[:id]) folder_environments = project.environments.where(environment_type: params[:id])
@environments = folder_environments.with_state(params[:scope] || :available) @environments = folder_environments.with_state(params[:scope] || :available)
.order(:name)
respond_to do |format| respond_to do |format|
format.html format.html
......
---
title: Sort folder for environments
merge_request:
author:
...@@ -84,6 +84,9 @@ describe Projects::EnvironmentsController do ...@@ -84,6 +84,9 @@ describe Projects::EnvironmentsController do
create(:environment, project: project, create(:environment, project: project,
name: 'staging-1.0/review', name: 'staging-1.0/review',
state: :available) state: :available)
create(:environment, project: project,
name: 'staging-1.0/preview',
state: :available)
end end
context 'when using default format' do context 'when using default format' do
...@@ -107,6 +110,8 @@ describe Projects::EnvironmentsController do ...@@ -107,6 +110,8 @@ describe Projects::EnvironmentsController do
expect(response).to be_ok expect(response).to be_ok
expect(response).not_to render_template 'folder' expect(response).not_to render_template 'folder'
expect(json_response['environments'][0]) expect(json_response['environments'][0])
.to include('name' => 'staging-1.0/preview')
expect(json_response['environments'][1])
.to include('name' => 'staging-1.0/review') .to include('name' => 'staging-1.0/review')
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