From e8f3dd07dd8462d8d80948d5c8f094bdcc966d9a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Barth Date: Wed, 29 Sep 2010 05:22:45 +0000 Subject: 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 --- test/unit/user_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index f3e56ddd3..b451c1e6b 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -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 -- cgit v1.2.3