Ability to close projects (read-only) (#3640).
A new permission (Close/reopen project) is available to give non-admin users the ability to close their projects. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9883 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Vendored
+1
@@ -8,6 +8,7 @@ roles_001:
|
||||
---
|
||||
- :add_project
|
||||
- :edit_project
|
||||
- :close_project
|
||||
- :select_project_modules
|
||||
- :manage_members
|
||||
- :manage_versions
|
||||
|
||||
@@ -380,6 +380,21 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||
assert_template 'settings'
|
||||
end
|
||||
|
||||
def test_settings_should_be_denied_for_member_on_closed_project
|
||||
Project.find(1).close
|
||||
@request.session[:user_id] = 2 # manager
|
||||
|
||||
get :settings, :id => 1
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_settings_should_be_denied_for_anonymous_on_closed_project
|
||||
Project.find(1).close
|
||||
|
||||
get :settings, :id => 1
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
def test_update
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :id => 1, :project => {:name => 'Test changed name',
|
||||
@@ -397,6 +412,23 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||
assert_error_tag :content => /name can't be blank/i
|
||||
end
|
||||
|
||||
def test_update_should_be_denied_for_member_on_closed_project
|
||||
Project.find(1).close
|
||||
@request.session[:user_id] = 2 # manager
|
||||
|
||||
post :update, :id => 1, :project => {:name => 'Closed'}
|
||||
assert_response 403
|
||||
assert_equal 'eCookbook', Project.find(1).name
|
||||
end
|
||||
|
||||
def test_update_should_be_denied_for_anonymous_on_closed_project
|
||||
Project.find(1).close
|
||||
|
||||
post :update, :id => 1, :project => {:name => 'Closed'}
|
||||
assert_response 302
|
||||
assert_equal 'eCookbook', Project.find(1).name
|
||||
end
|
||||
|
||||
def test_modules
|
||||
@request.session[:user_id] = 2
|
||||
Project.find(1).enabled_module_names = ['issue_tracking', 'news']
|
||||
@@ -444,6 +476,21 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||
assert Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_close
|
||||
@request.session[:user_id] = 2
|
||||
post :close, :id => 1
|
||||
assert_redirected_to '/projects/ecookbook'
|
||||
assert_equal Project::STATUS_CLOSED, Project.find(1).status
|
||||
end
|
||||
|
||||
def test_reopen
|
||||
Project.find(1).close
|
||||
@request.session[:user_id] = 2
|
||||
post :reopen, :id => 1
|
||||
assert_redirected_to '/projects/ecookbook'
|
||||
assert Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_project_breadcrumbs_should_be_limited_to_3_ancestors
|
||||
CustomField.delete_all
|
||||
parent = nil
|
||||
|
||||
@@ -69,6 +69,14 @@ class RoutingProjectsTest < ActionController::IntegrationTest
|
||||
{ :method => 'post', :path => "/projects/64/unarchive" },
|
||||
{ :controller => 'projects', :action => 'unarchive', :id => '64' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'post', :path => "/projects/64/close" },
|
||||
{ :controller => 'projects', :action => 'close', :id => '64' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'post', :path => "/projects/64/reopen" },
|
||||
{ :controller => 'projects', :action => 'reopen', :id => '64' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'put', :path => "/projects/4223" },
|
||||
{ :controller => 'projects', :action => 'update', :id => '4223' }
|
||||
|
||||
@@ -46,4 +46,14 @@ class Redmine::AccessControlTest < ActiveSupport::TestCase
|
||||
assert perm.actions.is_a?(Array)
|
||||
assert perm.actions.include?('projects/settings')
|
||||
end
|
||||
|
||||
def test_read_action_should_return_true_for_read_actions
|
||||
assert_equal true, @access_module.read_action?(:view_project)
|
||||
assert_equal true, @access_module.read_action?(:controller => 'projects', :action => 'show')
|
||||
end
|
||||
|
||||
def test_read_action_should_return_false_for_update_actions
|
||||
assert_equal false, @access_module.read_action?(:edit_project)
|
||||
assert_equal false, @access_module.read_action?(:controller => 'projects', :action => 'edit')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -874,6 +874,18 @@ class UserTest < ActiveSupport::TestCase
|
||||
assert ! @admin.allowed_to?(:view_issues, Project.find(1))
|
||||
end
|
||||
|
||||
should "return false for write action if project is closed" do
|
||||
project = Project.find(1)
|
||||
Project.any_instance.stubs(:status).returns(Project::STATUS_CLOSED)
|
||||
assert ! @admin.allowed_to?(:edit_project, Project.find(1))
|
||||
end
|
||||
|
||||
should "return true for read action if project is closed" do
|
||||
project = Project.find(1)
|
||||
Project.any_instance.stubs(:status).returns(Project::STATUS_CLOSED)
|
||||
assert @admin.allowed_to?(:view_project, Project.find(1))
|
||||
end
|
||||
|
||||
should "return false if related module is disabled" do
|
||||
project = Project.find(1)
|
||||
project.enabled_module_names = ["issue_tracking"]
|
||||
|
||||
Reference in New Issue
Block a user