summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-01-13 11:08:33 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-01-13 11:08:33 +0000
commit4f5d1b542ed815dfc842be675c332e4f09bddc7b (patch)
tree8c6fdd93d12d2493dcd5f1a323fbf94b922cb630
parent13c17c2ad5f7471a4dc638cba4dabd8514ab432a (diff)
downloadredmine-4f5d1b542ed815dfc842be675c332e4f09bddc7b.tar.gz
redmine-4f5d1b542ed815dfc842be675c332e4f09bddc7b.zip
Added tests on role inheritance for sub-projects.
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1061 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--project_inheritance/test/unit/user_test.rb56
1 files changed, 51 insertions, 5 deletions
diff --git a/project_inheritance/test/unit/user_test.rb b/project_inheritance/test/unit/user_test.rb
index 9f58d278f..2d60433b0 100644
--- a/project_inheritance/test/unit/user_test.rb
+++ b/project_inheritance/test/unit/user_test.rb
@@ -18,7 +18,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < Test::Unit::TestCase
- fixtures :users, :members, :projects
+ fixtures :users, :members, :projects, :roles
def setup
@admin = User.find(1)
@@ -103,16 +103,62 @@ class UserTest < Test::Unit::TestCase
assert_equal key, @jsmith.rss_key
end
- def test_role_for_project
- # user with a role
- role = @jsmith.role_for_project(Project.find(1))
+ def test_role_for_project_without_inheritance
+ Setting.subprojects_inherit_members = 0
+
+ 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
+
+ # not a member of the child
+ role = @jsmith.role_for_project(child)
assert_kind_of Role, role
- assert_equal "Manager", role.name
+ assert_equal 'Non member', role.name
+ assert !@jsmith.member_of?(child)
# user with no role
assert !@dlopper.role_for_project(Project.find(2)).member?
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
@jsmith.mail_notification = true
@jsmith.notified_project_ids = []