Added tests on role inheritance for sub-projects.
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1061 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
13c17c2ad5
commit
4f5d1b542e
1 file changed
+51
-5
@@ -18,7 +18,7 @@
|
|||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class UserTest < Test::Unit::TestCase
|
class UserTest < Test::Unit::TestCase
|
||||||
fixtures :users, :members, :projects
|
fixtures :users, :members, :projects, :roles
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@admin = User.find(1)
|
@admin = User.find(1)
|
||||||
@@ -103,16 +103,62 @@ class UserTest < Test::Unit::TestCase
|
|||||||
assert_equal key, @jsmith.rss_key
|
assert_equal key, @jsmith.rss_key
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_role_for_project
|
def test_role_for_project_without_inheritance
|
||||||
# user with a role
|
Setting.subprojects_inherit_members = 0
|
||||||
role = @jsmith.role_for_project(Project.find(1))
|
|
||||||
|
parent = Project.find(1)
|
||||||
|
child = parent.children.first
|
||||||
|
# user with a role on a parent project
|
||||||
|
role = @jsmith.role_for_project(parent)
|
||||||
assert_kind_of Role, role
|
assert_kind_of Role, role
|
||||||
assert_equal "Manager", role.name
|
assert_equal 'Manager', role.name
|
||||||
|
|
||||||
|
# not a member of the child
|
||||||
|
role = @jsmith.role_for_project(child)
|
||||||
|
assert_kind_of Role, role
|
||||||
|
assert_equal 'Non member', role.name
|
||||||
|
assert !@jsmith.member_of?(child)
|
||||||
|
|
||||||
# user with no role
|
# user with no role
|
||||||
assert !@dlopper.role_for_project(Project.find(2)).member?
|
assert !@dlopper.role_for_project(Project.find(2)).member?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_role_for_project_with_inheritance
|
||||||
|
Setting.subprojects_inherit_members = 1
|
||||||
|
|
||||||
|
parent = Project.find(1)
|
||||||
|
child = parent.children.first
|
||||||
|
# user with a role on a parent project
|
||||||
|
role = @jsmith.role_for_project(parent)
|
||||||
|
assert_kind_of Role, role
|
||||||
|
assert_equal 'Manager', role.name
|
||||||
|
|
||||||
|
# member of the child
|
||||||
|
role = @jsmith.role_for_project(child)
|
||||||
|
assert_kind_of Role, role
|
||||||
|
assert_equal 'Manager', role.name
|
||||||
|
assert @jsmith.member_of?(child)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_role_for_project_with_inheritance_and_role_override
|
||||||
|
Setting.subprojects_inherit_members = 1
|
||||||
|
|
||||||
|
parent = Project.find(1)
|
||||||
|
child = parent.children.first
|
||||||
|
Member.create!(:user => @jsmith, :project => child, :role => Role.find_by_name('Developer'))
|
||||||
|
|
||||||
|
# user with a role on a parent project
|
||||||
|
role = @jsmith.role_for_project(parent)
|
||||||
|
assert_kind_of Role, role
|
||||||
|
assert_equal 'Manager', role.name
|
||||||
|
|
||||||
|
# member of the child
|
||||||
|
role = @jsmith.role_for_project(child)
|
||||||
|
assert_kind_of Role, role
|
||||||
|
assert_equal 'Developer', role.name
|
||||||
|
assert @jsmith.member_of?(child)
|
||||||
|
end
|
||||||
|
|
||||||
def test_mail_notification_all
|
def test_mail_notification_all
|
||||||
@jsmith.mail_notification = true
|
@jsmith.mail_notification = true
|
||||||
@jsmith.notified_project_ids = []
|
@jsmith.notified_project_ids = []
|
||||||
|
|||||||
Reference in new issue
Block a user