mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
[31513] Re-add the parent_id in the SetAttributeService
https://community.openproject.com/wp/31513
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user