[31513] Re-add the parent_id in the SetAttributeService

https://community.openproject.com/wp/31513
pull/7821/head
Oliver Günther 5 years ago
parent 528b75641c
commit bcfec6ea11
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      app/controllers/projects_controller.rb
  2. 2
      app/helpers/projects_helper.rb
  3. 2
      app/views/project_settings/show.html.erb
  4. 11
      spec/controllers/projects_controller_spec.rb
  5. 3
      spec_legacy/functional/projects_controller_spec.rb

@ -70,7 +70,7 @@ class ProjectsController < ApplicationController
Projects::SetAttributesService
.new(user: current_user, model: @project, contract_class: EmptyContract)
.call({})
.call(params.permit(:parent_id))
render layout: 'no_menu'
end

@ -160,7 +160,7 @@ module ProjectsHelper
def project_more_menu_subproject_item(project)
if User.current.allowed_to? :add_subprojects, project
[t(:label_subproject_new),
new_project_path(parent_id: project),
new_project_path(parent_id: project.id),
class: 'icon-context icon-add',
title: t(:label_subproject_new)]
end

@ -31,7 +31,7 @@ See docs/COPYRIGHT.rdoc for more details.
<%= toolbar title: l(:label_project_settings) do %>
<% if User.current.allowed_to?(:add_subprojects, @project) %>
<li class="toolbar-item">
<%= link_to new_project_path(parent_id: @project),
<%= link_to new_project_path(parent_id: @project.id),
{ class: 'button -alt-highlight',
aria: {label: t(:label_subproject_new)},
title: t(:label_subproject_new)} do %>

@ -49,6 +49,17 @@ describe ProjectsController, type: :controller do
expect(response).to be_successful
expect(response).to render_template 'new'
end
context 'with parent project' do
let!(:parent) { FactoryBot.create :project, name: 'Parent' }
it 'sets the parent of the project' do
get 'new', params: { parent_id: parent.id }
expect(response).to be_successful
expect(response).to render_template 'new'
expect(assigns(:project).parent).to eq parent
end
end
end
describe 'index.html' do

@ -65,7 +65,8 @@ describe ProjectsController, type: :controller do
end
it 'should accept get' do
get :new, params: { parent_id: 'ecookbook' }
project = Project.find_by(identifier: 'ecookbook')
get :new, params: { parent_id: project.id }
assert_response :success
assert_template 'new'
# parent project selected

Loading…
Cancel
Save