Ability to allow non-admin users to create projects (#1007).
This can be enabled in permissions settings. A non-admin user who creates a project is automatically added as a project member (the first role is given, TODO: make this given role configurable). Projects can be added from the public projects list. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2750 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Vendored
+1
@@ -5,6 +5,7 @@ roles_001:
|
||||
builtin: 0
|
||||
permissions: |
|
||||
---
|
||||
- :add_project
|
||||
- :edit_project
|
||||
- :manage_members
|
||||
- :manage_versions
|
||||
|
||||
@@ -89,6 +89,56 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
)
|
||||
end
|
||||
|
||||
def test_get_add
|
||||
@request.session[:user_id] = 1
|
||||
get :add
|
||||
assert_response :success
|
||||
assert_template 'add'
|
||||
end
|
||||
|
||||
def test_get_add_by_non_admin
|
||||
@request.session[:user_id] = 2
|
||||
get :add
|
||||
assert_response :success
|
||||
assert_template 'add'
|
||||
end
|
||||
|
||||
def test_post_add
|
||||
@request.session[:user_id] = 1
|
||||
post :add, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' }
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
||||
project = Project.find_by_name('blog')
|
||||
assert_kind_of Project, project
|
||||
assert_equal 'weblog', project.description
|
||||
assert_equal true, project.is_public?
|
||||
end
|
||||
|
||||
def test_post_add_by_non_admin
|
||||
@request.session[:user_id] = 2
|
||||
post :add, :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' }
|
||||
}
|
||||
assert_redirected_to '/projects/blog/settings'
|
||||
|
||||
project = Project.find_by_name('blog')
|
||||
assert_kind_of Project, project
|
||||
assert_equal 'weblog', project.description
|
||||
assert_equal true, project.is_public?
|
||||
|
||||
# User should be added as a project member
|
||||
assert User.find(2).member_of?(project)
|
||||
assert_equal 1, project.members.size
|
||||
end
|
||||
|
||||
def test_show_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/test'},
|
||||
|
||||
@@ -39,28 +39,4 @@ class AdminTest < ActionController::IntegrationTest
|
||||
locked_user = User.try_to_login("psmith", "psmith09")
|
||||
assert_equal nil, locked_user
|
||||
end
|
||||
|
||||
def test_add_project
|
||||
log_user("admin", "admin")
|
||||
get "projects/new"
|
||||
assert_response :success
|
||||
assert_template "projects/add"
|
||||
post "projects", :project => { :name => "blog",
|
||||
:description => "weblog",
|
||||
:identifier => "blog",
|
||||
:is_public => 1,
|
||||
:custom_field_values => { '3' => 'Beta' }
|
||||
}
|
||||
assert_redirected_to "admin/projects"
|
||||
assert_equal 'Successful creation.', flash[:notice]
|
||||
|
||||
project = Project.find_by_name("blog")
|
||||
assert_kind_of Project, project
|
||||
assert_equal "weblog", project.description
|
||||
assert_equal true, project.is_public?
|
||||
|
||||
get "admin/projects"
|
||||
assert_response :success
|
||||
assert_template "admin/projects"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user