Added ability to specify multiple projects in User#allowed_to? (#5332)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4227 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Baptiste Barth
2010-09-29 05:22:45 +00:00
parent fda1a0cb3b
commit e8f3dd07dd
2 changed files with 26 additions and 3 deletions
+13
View File
@@ -396,6 +396,19 @@ class UserTest < ActiveSupport::TestCase
assert ! @dlopper.allowed_to?(:delete_messages, project) #Developper
end
end
context "with multiple projects" do
should "return false if array is empty" do
assert ! @admin.allowed_to?(:view_project, [])
end
should "return true only if user has permission on all these projects" do
assert @admin.allowed_to?(:view_project, Project.all)
assert ! @dlopper.allowed_to?(:view_project, Project.all) #cannot see Project(2)
assert @jsmith.allowed_to?(:edit_issues, @jsmith.projects) #Manager or Developer everywhere
assert ! @jsmith.allowed_to?(:delete_issue_watchers, @jsmith.projects) #Dev cannot delete_issue_watchers
end
end
context "with options[:global]" do
should "authorize if user has at least one role that has this permission" do