Commit b78ac977 authored by Peter Leitzen's avatar Peter Leitzen

Move settings operations controller from EE to CE

This commit prepares the structure for the upcoming feature error
tracking.
parent 1aa2ac13
# 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
...@@ -283,6 +283,11 @@ module ProjectsHelper ...@@ -283,6 +283,11 @@ module ProjectsHelper
!disabled && !compact_mode && Feature.enabled?(:project_list_show_issue_count, default_enabled: true) !disabled && !compact_mode && Feature.enabled?(:project_list_show_issue_count, default_enabled: true)
end end
# overridden in EE
def settings_operations_available?
false
end
private private
def get_project_nav_tabs(project, current_user) def get_project_nav_tabs(project, current_user)
......
# 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
...@@ -339,7 +339,10 @@ ...@@ -339,7 +339,10 @@
= link_to project_settings_ci_cd_path(@project), title: _('CI / CD') do = link_to project_settings_ci_cd_path(@project), title: _('CI / CD') do
%span %span
= _('CI / CD') = _('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? - if @project.pages_available?
= nav_link(controller: :pages) do = nav_link(controller: :pages) do
= link_to project_pages_path(@project), title: _('Pages') do = link_to project_pages_path(@project), title: _('Pages') do
......
- @content_class = 'limit-container-width' unless fluid_layout
- page_title _('Operations')
= render_if_exists 'projects/settings/operations/tracing'
...@@ -445,6 +445,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -445,6 +445,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# its preferable to keep it below all other project routes # its preferable to keep it below all other project routes
draw :wiki draw :wiki
draw :repository draw :repository
namespace :settings do
resource :operations, only: [:show, :update]
end
end end
resources(:projects, resources(:projects,
......
...@@ -7818,6 +7818,9 @@ msgstr "" ...@@ -7818,6 +7818,9 @@ msgstr ""
msgid "Your changes have been committed. Commit %{commitId} %{commitStats}" msgid "Your changes have been committed. Commit %{commitId} %{commitStats}"
msgstr "" msgstr ""
msgid "Your changes have been saved"
msgstr ""
msgid "Your comment will not be visible to the public." msgid "Your comment will not be visible to the public."
msgstr "" msgstr ""
......
# 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
# 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
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