summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Leitzen <pleitzen@gitlab.com>2019-01-06 13:59:10 +0100
committerPeter Leitzen <pleitzen@gitlab.com>2019-01-06 15:13:14 +0100
commitb78ac977eeb8d631ff6c56674d8c081a3249138b (patch)
tree96e1ce80845578485c2229d8e51e940910f9ac44
parent1aa2ac13b95b9fa9527596610bb07e132dc1a6f0 (diff)
downloadgitlab-ce-move-settings-oprations-to-ce.tar.gz
Move settings operations controller from EE to CEmove-settings-oprations-to-ce
This commit prepares the structure for the upcoming feature error tracking.
-rw-r--r--app/controllers/projects/settings/operations_controller.rb39
-rw-r--r--app/helpers/projects_helper.rb5
-rw-r--r--app/services/projects/operations/update_service.rb19
-rw-r--r--app/views/layouts/nav/sidebar/_project.html.haml5
-rw-r--r--app/views/projects/settings/operations/show.html.haml4
-rw-r--r--config/routes/project.rb4
-rw-r--r--locale/gitlab.pot3
-rw-r--r--spec/controllers/projects/settings/operations_controller_spec.rb35
-rw-r--r--spec/services/projects/operations/update_service_spec.rb25
9 files changed, 138 insertions, 1 deletions
diff --git a/app/controllers/projects/settings/operations_controller.rb b/app/controllers/projects/settings/operations_controller.rb
new file mode 100644
index 00000000000..ae8ac61ad46
--- /dev/null
+++ b/app/controllers/projects/settings/operations_controller.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+module Projects
+ module Settings
+ class OperationsController < Projects::ApplicationController
+ before_action :check_license
+ before_action :authorize_update_environment!
+
+ def show
+ end
+
+ def update
+ result = ::Projects::Operations::UpdateService.new(project, current_user, update_params).execute
+
+ if result[:status] == :success
+ flash[:notice] = _('Your changes have been saved')
+ redirect_to project_settings_operations_path(@project)
+ else
+ render 'show'
+ end
+ end
+
+ private
+
+ def update_params
+ params.require(:project).permit(permitted_project_params)
+ end
+
+ # overridden in EE
+ def permitted_project_params
+ {}
+ end
+
+ def check_license
+ render_404 unless helpers.settings_operations_available?
+ end
+ end
+ end
+end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 2a673915a61..fcab8cc3380 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -283,6 +283,11 @@ module ProjectsHelper
!disabled && !compact_mode && Feature.enabled?(:project_list_show_issue_count, default_enabled: true)
end
+ # overridden in EE
+ def settings_operations_available?
+ false
+ end
+
private
def get_project_nav_tabs(project, current_user)
diff --git a/app/services/projects/operations/update_service.rb b/app/services/projects/operations/update_service.rb
new file mode 100644
index 00000000000..7ff0599ee95
--- /dev/null
+++ b/app/services/projects/operations/update_service.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Projects
+ module Operations
+ class UpdateService < BaseService
+ def execute
+ Projects::UpdateService
+ .new(project, current_user, project_update_params)
+ .execute
+ end
+
+ private
+
+ def project_update_params
+ {}
+ end
+ end
+ end
+end
diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml
index d8017742c90..e516c76400a 100644
--- a/app/views/layouts/nav/sidebar/_project.html.haml
+++ b/app/views/layouts/nav/sidebar/_project.html.haml
@@ -339,7 +339,10 @@
= link_to project_settings_ci_cd_path(@project), title: _('CI / CD') do
%span
= _('CI / CD')
- = render_if_exists 'projects/sidebar/settings_operations'
+ - if settings_operations_available?
+ = nav_link(controller: [:operations]) do
+ = link_to project_settings_operations_path(@project), title: _('Operations') do
+ = _('Operations')
- if @project.pages_available?
= nav_link(controller: :pages) do
= link_to project_pages_path(@project), title: _('Pages') do
diff --git a/app/views/projects/settings/operations/show.html.haml b/app/views/projects/settings/operations/show.html.haml
new file mode 100644
index 00000000000..0782029dbcd
--- /dev/null
+++ b/app/views/projects/settings/operations/show.html.haml
@@ -0,0 +1,4 @@
+- @content_class = 'limit-container-width' unless fluid_layout
+- page_title _('Operations')
+
+= render_if_exists 'projects/settings/operations/tracing'
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 03c95b61e51..f50bf5ab76f 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -445,6 +445,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# its preferable to keep it below all other project routes
draw :wiki
draw :repository
+
+ namespace :settings do
+ resource :operations, only: [:show, :update]
+ end
end
resources(:projects,
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index ed8d4e81e90..1bb94c5a61a 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -7818,6 +7818,9 @@ msgstr ""
msgid "Your changes have been committed. Commit %{commitId} %{commitStats}"
msgstr ""
+msgid "Your changes have been saved"
+msgstr ""
+
msgid "Your comment will not be visible to the public."
msgstr ""
diff --git a/spec/controllers/projects/settings/operations_controller_spec.rb b/spec/controllers/projects/settings/operations_controller_spec.rb
new file mode 100644
index 00000000000..fbb26de76d1
--- /dev/null
+++ b/spec/controllers/projects/settings/operations_controller_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Projects::Settings::OperationsController do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+
+ before do
+ sign_in(user)
+ project.add_maintainer(user)
+ end
+
+ describe 'GET #show' do
+ it 'returns 404' do
+ get :show, params: project_params(project)
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ describe 'PATCH #update' do
+ it 'returns 404' do
+ patch :update, params: project_params(project)
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ private
+
+ def project_params(project)
+ { namespace_id: project.namespace, project_id: project }
+ end
+end
diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb
new file mode 100644
index 00000000000..332c1600cde
--- /dev/null
+++ b/spec/services/projects/operations/update_service_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Projects::Operations::UpdateService do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+
+ let(:result) { subject.execute }
+
+ subject { described_class.new(project, user, params) }
+
+ describe '#execute' do
+ context 'with inappropriate params' do
+ let(:params) { { name: '' } }
+
+ let!(:original_name) { project.name }
+
+ it 'ignores params' do
+ expect(result[:status]).to eq(:success)
+ expect(project.reload.name).to eq(original_name)
+ end
+ end
+ end
+end