incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [2/3] git commit: [#6306] ticket:368 Add test for User.my_projects() with given role
Date Thu, 27 Jun 2013 14:06:47 GMT
[#6306] ticket:368 Add test for User.my_projects() with given role


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3b1e1425
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3b1e1425
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3b1e1425

Branch: refs/heads/master
Commit: 3b1e1425a3a4e6f22fe9e9052c54ed0f6d75c32a
Parents: e1b23c3
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Jun 20 16:28:15 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Jun 27 14:05:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_auth.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3b1e1425/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index ea160fe..c157b2e 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -189,3 +189,21 @@ def test_email_address_claimed_by_user():
     c.user.disabled = True
     ThreadLocalORMSession.flush_all()
     assert addr.claimed_by_user() is None
+
+
+@td.with_user_project('test-admin')
+@with_setup(setUp)
+def test_user_projects_by_role():
+    assert_equal(set(p.shortname for p in c.user.my_projects()), set(['test', 'test2', 'u/test-admin',
'adobe-1', '--init--']))
+    assert_equal(set(p.shortname for p in c.user.my_projects('Admin')), set(['test', 'test2',
'u/test-admin', 'adobe-1', '--init--']))
+    # Remove admin access from c.user to test2 project
+    project = M.Project.query.get(shortname='test2')
+    admin_role = M.ProjectRole.by_name('Admin', project)
+    developer_role = M.ProjectRole.by_name('Developer', project)
+    user_role = c.user.project_role(project)
+    user_role.roles.remove(admin_role._id)
+    user_role.roles.append(developer_role._id)
+    ThreadLocalORMSession.flush_all()
+    g.credentials.clear()
+    assert_equal(set(p.shortname for p in c.user.my_projects()), set(['test', 'test2', 'u/test-admin',
'adobe-1', '--init--']))
+    assert_equal(set(p.shortname for p in c.user.my_projects('Admin')), set(['test', 'u/test-admin',
'adobe-1', '--init--']))


Mime
View raw message