summaryrefslogtreecommitdiffstats
path: root/test/unit/member_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-31 07:16:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-31 07:16:23 +0000
commited9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b (patch)
tree3420c99029f21a21c236c4ff8c0c532dd548401e /test/unit/member_test.rb
parent48d40a8c8884aefc2287f2030c439578057c9516 (diff)
downloadredmine-ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b.tar.gz
redmine-ed9f00178c65cc4b37ad2ab56cc89b1c79c4fb8b.zip
Ability to limit member management to certain roles (#19707).
git-svn-id: http://svn.redmine.org/redmine/trunk@14293 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/member_test.rb')
-rw-r--r--test/unit/member_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/unit/member_test.rb b/test/unit/member_test.rb
index 2ed65543b..221cae4f8 100644
--- a/test/unit/member_test.rb
+++ b/test/unit/member_test.rb
@@ -159,4 +159,35 @@ class MemberTest < ActiveSupport::TestCase
assert_equal -1, a <=> b
assert_equal 1, b <=> a
end
+
+ def test_managed_roles_should_return_all_roles_for_role_with_all_roles_managed
+ member = Member.new
+ member.roles << Role.generate!(:permissions => [:manage_members], :all_roles_managed => true)
+ assert_equal Role.givable.all, member.managed_roles
+ end
+
+ def test_managed_roles_should_return_all_roles_for_admins
+ member = Member.new(:user => User.find(1))
+ member.roles << Role.generate!
+ assert_equal Role.givable.all, member.managed_roles
+ end
+
+ def test_managed_roles_should_return_limited_roles_for_role_without_all_roles_managed
+ member = Member.new
+ member.roles << Role.generate!(:permissions => [:manage_members], :all_roles_managed => false, :managed_role_ids => [2, 3])
+ assert_equal [2, 3], member.managed_roles.map(&:id).sort
+ end
+
+ def test_managed_roles_should_cumulated_managed_roles
+ member = Member.new
+ member.roles << Role.generate!(:permissions => [:manage_members], :all_roles_managed => false, :managed_role_ids => [3])
+ member.roles << Role.generate!(:permissions => [:manage_members], :all_roles_managed => false, :managed_role_ids => [2])
+ assert_equal [2, 3], member.managed_roles.map(&:id).sort
+ end
+
+ def test_managed_roles_should_return_no_roles_for_role_without_permission
+ member = Member.new
+ member.roles << Role.generate!(:all_roles_managed => true)
+ assert_equal [], member.managed_roles
+ end
end