diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-06-26 10:36:16 +0100 |
---|---|---|
committer | Jose <jvargas@gitlab.com> | 2018-06-26 23:06:25 -0500 |
commit | 91463e52467d4b93d95693ac4eba1d5630ecdc98 (patch) | |
tree | dabe37b1c6a169d59e1611d17e0157cf0516e33b | |
parent | c4df74d1e1ba53996c0d64a8f8ef91712bbecf75 (diff) | |
download | gitlab-ce-91463e52467d4b93d95693ac4eba1d5630ecdc98.tar.gz |
Specify environment actions to distinguish between metrics and every other environment related actions
7 files changed, 46 insertions, 8 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 47b2028860d..decef19a0a2 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -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 diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index 07249fe3182..199a8a4c4c5 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -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 diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb index f5cf089ad98..14e84f6a65f 100644 --- a/app/controllers/projects/uploads_controller.rb +++ b/app/controllers/projects/uploads_controller.rb @@ -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] diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index 4096a0f4c31..a1a14aec5c6 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -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') diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index 47d4942acbd..36ebbc8a016 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -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) diff --git a/spec/features/projects/user_uses_shortcuts_spec.rb b/spec/features/projects/user_uses_shortcuts_spec.rb index 495a010b32c..806460ba4d4 100644 --- a/spec/features/projects/user_uses_shortcuts_spec.rb +++ b/spec/features/projects/user_uses_shortcuts_spec.rb @@ -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') diff --git a/spec/helpers/environments_helper_spec.rb b/spec/helpers/environments_helper_spec.rb new file mode 100644 index 00000000000..c6810f9003d --- /dev/null +++ b/spec/helpers/environments_helper_spec.rb @@ -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 |