From c9a7145a100d24c6dbed98d11b0bc3af7a97cdb7 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Fri, 29 Jun 2018 10:02:32 +0200 Subject: [PATCH] Remove GET empty from EnvironmentsController --- .../projects/environments_controller.rb | 17 +++++------------ .../layouts/nav/sidebar/_project.html.haml | 2 +- config/routes/project.rb | 1 - .../projects/environments_controller_spec.rb | 13 ++----------- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 53da384dc74..1a586105a6d 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -120,21 +120,14 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end - def empty - render :empty - end - def metrics_redirect environment = project.environments.with_state(:available).first - path = - if environment - environment_metrics_path(environment) - else - empty_project_environments_path(project) - end - - redirect_to path + if environment + redirect_to environment_metrics_path(environment) + else + render :empty + end end def metrics diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index a1763393d25..bb34bbb4bde 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -210,7 +210,7 @@ %li.divider.fly-out-top-item - if project_nav_tab? :environments - = nav_link(controller: :environments, action: [:metrics, :empty]) do + = nav_link(controller: :environments, action: [:metrics, :metrics_redirect]) do = link_to metrics_project_environments_path(@project), title: 'Metrics', class: 'shortcuts-metrics' do %span = _('Metrics') diff --git a/config/routes/project.rb b/config/routes/project.rb index 18685d3acfd..286b96d765b 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -236,7 +236,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do collection do get :metrics, action: :metrics_redirect - get :empty get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ } end diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index f6ce4c20d5b..cb561e24762 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -277,16 +277,6 @@ describe Projects::EnvironmentsController do end end - describe 'GET #empty' do - it 'responds with HTML' do - get :empty, namespace_id: project.namespace, - project_id: project - - expect(response).to be_ok - expect(response).to render_template 'empty' - end - end - describe 'GET #metrics_redirect' do let(:project) { create(:project) } @@ -301,7 +291,8 @@ describe Projects::EnvironmentsController do it 'redirects to empty page if no environment exists' do get :metrics_redirect, environment_params - expect(response).to redirect_to(empty_project_environments_path(project)) + expect(response).to be_ok + expect(response).to render_template 'empty' end end