@@ -680,12 +680,14 class Project < ActiveRecord::Base | |||
|
680 | 680 | attrs = attrs.deep_dup |
|
681 | 681 | |
|
682 | 682 | @unallowed_parent_id = nil |
|
683 | parent_id_param = attrs['parent_id'].to_s | |
|
684 |
|
|
|
685 | p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil | |
|
686 | unless allowed_parents(user).include?(p) | |
|
687 | attrs.delete('parent_id') | |
|
688 | @unallowed_parent_id = true | |
|
683 | if new_record? || attrs.key?('parent_id') | |
|
684 | parent_id_param = attrs['parent_id'].to_s | |
|
685 | if new_record? || parent_id_param != parent_id.to_s | |
|
686 | p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil | |
|
687 | unless allowed_parents(user).include?(p) | |
|
688 | attrs.delete('parent_id') | |
|
689 | @unallowed_parent_id = true | |
|
690 | end | |
|
689 | 691 | end |
|
690 | 692 | end |
|
691 | 693 |
@@ -486,6 +486,17 class ProjectsControllerTest < ActionController::TestCase | |||
|
486 | 486 | assert_equal 'eCookbook', Project.find(1).name |
|
487 | 487 | end |
|
488 | 488 | |
|
489 | def test_update_child_project_without_parent_permission_should_not_show_validation_error | |
|
490 | child = Project.generate_with_parent! | |
|
491 | user = User.generate! | |
|
492 | User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project])) | |
|
493 | @request.session[:user_id] = user.id | |
|
494 | ||
|
495 | post :update, :id => child.id, :project => {:name => 'Updated'} | |
|
496 | assert_response 302 | |
|
497 | assert_match /Successful update/, flash[:notice] | |
|
498 | end | |
|
499 | ||
|
489 | 500 | def test_modules |
|
490 | 501 | @request.session[:user_id] = 2 |
|
491 | 502 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] |
@@ -39,7 +39,10 module ObjectHelpers | |||
|
39 | 39 | project |
|
40 | 40 | end |
|
41 | 41 | |
|
42 |
def Project.generate_with_parent!( |
|
|
42 | def Project.generate_with_parent!(*args) | |
|
43 | attributes = args.last.is_a?(Hash) ? args.pop : {} | |
|
44 | parent = args.size > 0 ? args.first : Project.generate! | |
|
45 | ||
|
43 | 46 | project = Project.generate!(attributes) do |p| |
|
44 | 47 | p.parent = parent |
|
45 | 48 | end |
General Comments 0
You need to be logged in to leave comments.
Login now