Allow non admin users to add subprojects (#2963).
Subprojects can be added to the projects for which the user has add_project permission. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3059 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -117,6 +117,23 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||
assert_kind_of Project, project
|
||||
assert_equal 'weblog', project.description
|
||||
assert_equal true, project.is_public?
|
||||
assert_nil project.parent
|
||||
end
|
||||
|
||||
def test_post_add_subproject
|
||||
@request.session[:user_id] = 1
|
||||
post :add, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' },
|
||||
:parent_id => 1
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
||||
project = Project.find_by_name('blog')
|
||||
assert_kind_of Project, project
|
||||
assert_equal Project.find(1), project.parent
|
||||
end
|
||||
|
||||
def test_post_add_by_non_admin
|
||||
|
||||
@@ -26,6 +26,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@ecookbook = Project.find(1)
|
||||
@ecookbook_sub1 = Project.find(3)
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
should_validate_presence_of :name
|
||||
@@ -236,6 +237,14 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
assert_equal [5, 6, 3, 4], d.collect(&:id)
|
||||
end
|
||||
|
||||
def test_allowed_parents_should_be_empty_for_non_member_user
|
||||
Role.non_member.add_permission!(:add_project)
|
||||
user = User.find(9)
|
||||
assert user.memberships.empty?
|
||||
User.current = user
|
||||
assert Project.new.allowed_parents.empty?
|
||||
end
|
||||
|
||||
def test_users_by_role
|
||||
users_by_role = Project.find(1).users_by_role
|
||||
assert_kind_of Hash, users_by_role
|
||||
|
||||
Reference in New Issue
Block a user