Commit 35ab669a authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'zj-sort-env-folders' into 'master'

Sort environments folders when opening them

Closes #30814

See merge request !11436
parents d7157746 5c83d3af
......@@ -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
......
---
title: Sort folder for environments
merge_request:
author:
require 'spec_helper'
describe Projects::EnvironmentsController do
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
set(:user) { create(:user) }
set(:project) { create(:empty_project) }
let(:environment) do
set(:environment) do
create(:environment, name: 'production', project: project)
end
before do
project.team << [user, :master]
project.add_master(user)
sign_in(user)
end
describe 'GET index' do
context 'when standardrequest has been made' do
context 'when a request for the HTML is made' do
it 'responds with status code 200' do
get :index, environment_params
expect(response).to be_ok
expect(response).to have_http_status(:ok)
end
end
......@@ -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/zzz',
state: :available)
end
context 'when using default format' do
......@@ -98,7 +101,7 @@ describe Projects::EnvironmentsController do
end
context 'when using JSON format' do
it 'responds with JSON' do
it 'sorts the subfolders lexicographically' do
get :folder, namespace_id: project.namespace,
project_id: project,
id: 'staging-1.0',
......@@ -108,6 +111,8 @@ describe Projects::EnvironmentsController do
expect(response).not_to render_template 'folder'
expect(json_response['environments'][0])
.to include('name' => 'staging-1.0/review')
expect(json_response['environments'][1])
.to include('name' => 'staging-1.0/zzz')
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