@@ -700,12 +700,14 class Project < ActiveRecord::Base | |||
|
700 | 700 | attrs = attrs.deep_dup |
|
701 | 701 | |
|
702 | 702 | @unallowed_parent_id = nil |
|
703 | parent_id_param = attrs['parent_id'].to_s | |
|
704 |
|
|
|
705 | p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil | |
|
706 | unless allowed_parents(user).include?(p) | |
|
707 | attrs.delete('parent_id') | |
|
708 | @unallowed_parent_id = true | |
|
703 | if new_record? || attrs.key?('parent_id') | |
|
704 | parent_id_param = attrs['parent_id'].to_s | |
|
705 | if new_record? || parent_id_param != parent_id.to_s | |
|
706 | p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil | |
|
707 | unless allowed_parents(user).include?(p) | |
|
708 | attrs.delete('parent_id') | |
|
709 | @unallowed_parent_id = true | |
|
710 | end | |
|
709 | 711 | end |
|
710 | 712 | end |
|
711 | 713 |
@@ -495,6 +495,17 class ProjectsControllerTest < ActionController::TestCase | |||
|
495 | 495 | assert_equal 'eCookbook', Project.find(1).name |
|
496 | 496 | end |
|
497 | 497 | |
|
498 | def test_update_child_project_without_parent_permission_should_not_show_validation_error | |
|
499 | child = Project.generate_with_parent! | |
|
500 | user = User.generate! | |
|
501 | User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project])) | |
|
502 | @request.session[:user_id] = user.id | |
|
503 | ||
|
504 | post :update, :id => child.id, :project => {:name => 'Updated'} | |
|
505 | assert_response 302 | |
|
506 | assert_match /Successful update/, flash[:notice] | |
|
507 | end | |
|
508 | ||
|
498 | 509 | def test_modules |
|
499 | 510 | @request.session[:user_id] = 2 |
|
500 | 511 | 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