reenabled select_project_modules permission

pull/9779/head
ulferts 3 years ago
parent a7ca07bfab
commit 9ecd930d52
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 15
      app/controllers/project_settings/modules_controller.rb
  2. 15
      app/controllers/projects_controller.rb
  3. 4
      app/views/project_settings/modules.html.erb
  4. 5
      config/initializers/permissions.rb
  5. 1
      config/routes.rb
  6. 12
      spec/controllers/projects_controller_spec.rb
  7. 6
      spec/routing/project_routing_spec.rb
  8. 7
      spec/routing/project_settings_routing_spec.rb

@ -34,4 +34,19 @@ class ProjectSettings::ModulesController < ProjectSettingsController
def show def show
render template: 'project_settings/modules' render template: 'project_settings/modules'
end end
def update
call = Projects::EnabledModulesService
.new(model: @project, user: current_user)
.call(enabled_modules: permitted_params.project[:enabled_module_names])
if call.success?
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to settings_modules_project_path(@project)
else
@errors = call.errors
render 'project_settings/modules'
end
end
end end

@ -83,21 +83,6 @@ class ProjectsController < ApplicationController
end end
end end
def modules
call = Projects::EnabledModulesService
.new(model: @project, user: current_user)
.call(enabled_modules: permitted_params.project[:enabled_module_names])
if call.success?
flash[:notice] = I18n.t(:notice_successful_update)
redirect_to settings_modules_project_path(@project)
else
@errors = call.errors
render 'project_settings/modules'
end
end
def custom_fields def custom_fields
Project.transaction do Project.transaction do
@project.work_package_custom_field_ids = permitted_params.project[:work_package_custom_field_ids] @project.work_package_custom_field_ids = permitted_params.project[:work_package_custom_field_ids]

@ -34,8 +34,8 @@ See COPYRIGHT and LICENSE files for more details.
<%= error_messages_for_contract(@project, @errors) %> <%= error_messages_for_contract(@project, @errors) %>
<%= labelled_tabular_form_for @project, <%= labelled_tabular_form_for @project,
url: modules_project_path(@project), url: settings_modules_project_path(@project),
method: :put do |form| %> method: :patch do |form| %>
<%= render partial: "/projects/form/modules", <%= render partial: "/projects/form/modules",
locals: { form: form } %> locals: { form: form } %>

@ -83,7 +83,10 @@ OpenProject::AccessControl.map do |map|
contract_actions: { projects: %i[update] } contract_actions: { projects: %i[update] }
map.permission :select_project_modules, map.permission :select_project_modules,
{ projects: :modules }, {
projects: :modules,
'project_settings/modules': %i[show update]
},
require: :member, require: :member,
dependencies: :edit_project dependencies: :edit_project

@ -199,7 +199,6 @@ OpenProject::Application.routes.draw do
get :copy get :copy
put :modules
put :custom_fields put :custom_fields
put :archive put :archive
put :unarchive put :unarchive

@ -213,18 +213,6 @@ describe ProjectsController, type: :controller do
describe 'with an existing project' do describe 'with an existing project' do
let(:project) { FactoryBot.create :project, identifier: 'blog' } let(:project) { FactoryBot.create :project, identifier: 'blog' }
it 'should modules' do
project.enabled_module_names = %w[work_package_tracking news]
put :modules, params: {
id: project.id,
project: {
enabled_module_names: %w[work_package_tracking repository]
}
}
expect(response).to redirect_to '/projects/blog/settings/modules'
expect(project.reload.enabled_module_names.sort).to eq %w[repository work_package_tracking]
end
it 'should get destroy info' do it 'should get destroy info' do
get :destroy_info, params: { id: project.id } get :destroy_info, params: { id: project.id }
expect(response).to be_successful expect(response).to be_successful

@ -96,12 +96,6 @@ describe ProjectsController, type: :routing do
end end
describe 'miscellaneous' do describe 'miscellaneous' do
it do
expect(put('projects/123/modules')).to route_to(
controller: 'projects', action: 'modules', id: '123'
)
end
it do it do
expect(put('projects/123/custom_fields')).to route_to( expect(put('projects/123/custom_fields')).to route_to(
controller: 'projects', action: 'custom_fields', id: '123' controller: 'projects', action: 'custom_fields', id: '123'

@ -42,6 +42,13 @@ describe ProjectSettingsController, type: :routing do
) )
end end
it do
expect(patch('/projects/123/settings/modules'))
.to route_to(
controller: 'project_settings/modules', action: 'update', id: '123'
)
end
it do it do
expect(get('/projects/123/settings/custom_fields')).to route_to( expect(get('/projects/123/settings/custom_fields')).to route_to(
controller: 'project_settings/custom_fields', action: 'show', id: '123' controller: 'project_settings/custom_fields', action: 'show', id: '123'

Loading…
Cancel
Save