Specify environment actions to distinguish between metrics and every other environment related actions
This commit is contained in:
parent
c4df74d1e1
commit
91463e5246
7 changed files with 46 additions and 8 deletions
|
@ -31,10 +31,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def empty
|
||||
render :empty
|
||||
end
|
||||
|
||||
def folder
|
||||
folder_environments = project.environments.where(environment_type: params[:id])
|
||||
@environments = folder_environments.with_state(params[:scope] || :available)
|
||||
|
@ -124,6 +120,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def empty
|
||||
render :empty
|
||||
end
|
||||
|
||||
def metrics
|
||||
# Currently, this acts as a hint to load the metrics details into the cache
|
||||
# if they aren't there already
|
||||
|
|
|
@ -15,6 +15,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
|
|||
# Git clients will not know what authenticity token to send along
|
||||
skip_before_action :verify_authenticity_token
|
||||
skip_before_action :repository
|
||||
skip_before_action :available_environment
|
||||
before_action :authenticate_user
|
||||
|
||||
private
|
||||
|
|
|
@ -2,7 +2,7 @@ class Projects::UploadsController < Projects::ApplicationController
|
|||
include UploadsActions
|
||||
|
||||
# These will kick you out if you don't have access.
|
||||
skip_before_action :project, :repository,
|
||||
skip_before_action :project, :repository, :available_environment,
|
||||
if: -> { action_name == 'show' && image_or_video? }
|
||||
|
||||
before_action :authorize_upload_file!, only: [:create]
|
||||
|
|
|
@ -204,18 +204,18 @@
|
|||
|
||||
%ul.sidebar-sub-level-items
|
||||
= nav_link(controller: [:environments, :clusters, :user, :gcp], html_options: { class: "fly-out-top-item" } ) do
|
||||
= link_to project_environments_path(@project) do
|
||||
= link_to operations_metrics_path(@project, @available_environment) do
|
||||
%strong.fly-out-top-item-name
|
||||
= _('Operations')
|
||||
%li.divider.fly-out-top-item
|
||||
|
||||
- if project_nav_tab? :environments
|
||||
= nav_link(controller: [:environments, :metrics]) do
|
||||
= nav_link(controller: :environments, action: [:metrics, :empty]) do
|
||||
= link_to operations_metrics_path(@project, @available_environment), title: 'Metrics', class: 'shortcuts-environments' do
|
||||
%span
|
||||
= _('Metrics')
|
||||
|
||||
= nav_link(controller: :environments) do
|
||||
= nav_link(controller: :environments, action: [:index, :folder, :show, :new, :edit, :create, :update, :stop, :terminal]) do
|
||||
= link_to project_environments_path(@project), title: 'Environments', class: 'shortcuts-environments' do
|
||||
%span
|
||||
= _('Environments')
|
||||
|
|
|
@ -277,6 +277,16 @@ 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' do
|
||||
before do
|
||||
allow(controller).to receive(:environment).and_return(environment)
|
||||
|
|
|
@ -110,6 +110,14 @@ describe 'User uses shortcuts', :js do
|
|||
end
|
||||
|
||||
context 'when navigating to the Operations pages' do
|
||||
it 'redirects to the Metrics page' do
|
||||
find('body').native.send_key('g')
|
||||
find('body').native.send_key('m')
|
||||
|
||||
expect(page).to have_active_navigation('Operations')
|
||||
expect(page).to have_active_sub_navigation('Metrics')
|
||||
end
|
||||
|
||||
it 'redirects to the Environments page' do
|
||||
find('body').native.send_key('g')
|
||||
find('body').native.send_key('e')
|
||||
|
|
19
spec/helpers/environments_helper_spec.rb
Normal file
19
spec/helpers/environments_helper_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe EnvironmentsHelper do
|
||||
include ApplicationHelper
|
||||
|
||||
describe 'operations_metrics_path' do
|
||||
let(:project) { create(:project) }
|
||||
|
||||
it 'returns empty metrics path when environment is nil' do
|
||||
expect(helper.operations_metrics_path(project, nil)).to eq(empty_project_environments_path(project))
|
||||
end
|
||||
|
||||
it 'returns environment metrics path when environment is passed' do
|
||||
environment = create(:environment, project: project)
|
||||
|
||||
expect(helper.operations_metrics_path(project, environment)).to eq(environment_metrics_path(environment))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue