You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/02/13 21:21:31 UTC

[3/8] git commit: [#6677] add comment, and positive test

[#6677] add comment, and positive test


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

Branch: refs/heads/cj/7097
Commit: 87259aa02afc635d8f2d41ae88a3a7ace66760df
Parents: 6939145
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Feb 13 17:33:13 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Feb 13 17:33:17 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            | 1 +
 Allura/allura/tests/model/test_auth.py | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/87259aa0/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index aa8e5dc..0a68146 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -747,6 +747,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
         if self.is_anonymous():
             return
         roles = g.credentials.user_roles(user_id=self._id)
+        # filter out projects to which the user belongs to no named groups (i.e., role['roles'] is empty)
         projects = [r['project_id'] for r in roles if r['roles']]
         from .project import Project
         return Project.query.find({'_id': {'$in': projects}, 'deleted': False})

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/87259aa0/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 606b3e2..475b74a 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -20,7 +20,7 @@
 """
 Model tests for auth
 """
-from nose.tools import with_setup, assert_equal, assert_not_in
+from nose.tools import with_setup, assert_equal, assert_not_in, assert_in
 from pylons import tmpl_context as c, app_globals as g
 from webob import Request
 from mock import patch
@@ -268,7 +268,9 @@ def test_user_projects_unnamed():
         user_id=c.user._id,
         project_id=sub1._id)
     ThreadLocalORMSession.flush_all()
-    assert_not_in('test/sub1', [p.shortname for p in c.user.my_projects()])
+    project_names = [p.shortname for p in c.user.my_projects()]
+    assert_not_in('test/sub1', project_names)
+    assert_in('test', project_names)
 
 
 @patch.object(g, 'user_message_max_messages', 3)