incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [8/49] git commit: [#5342] Fixed 500 error when viewing profile for missing user
Date Fri, 07 Dec 2012 22:26:35 GMT
[#5342] Fixed 500 error when viewing profile for missing user

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/db/4803
Commit: 73b4fba05684d4d0a402d555d425d2a54ffe730d
Parents: be14410
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Dec 4 19:38:07 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Thu Dec 6 16:49:39 2012 +0000

----------------------------------------------------------------------
 Allura/allura/ext/user_profile/user_main.py        |    6 +++++-
 .../allura/tests/functional/test_user_profile.py   |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/73b4fba0/Allura/allura/ext/user_profile/user_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index f4a1abd..f631fd5 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -5,6 +5,7 @@ import pkg_resources
 from pylons import c, g, request
 from formencode import validators
 from tg import expose, redirect, validate, response
+from webob import exc
 
 from allura import version
 from allura.app import Application
@@ -59,7 +60,10 @@ class UserProfileController(BaseController):
 
     @expose('jinja:allura.ext.user_profile:templates/user_index.html')
     def index(self, **kw):
-        return dict(user=c.project.user_project_of)
+        user = c.project.user_project_of
+        if not user:
+            raise exc.HTTPNotFound()
+        return dict(user=user)
     # This will be fully implemented in a future iteration
     # @expose('jinja:allura.ext.user_profile:templates/user_subscriptions.html')
     # def subscriptions(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/73b4fba0/Allura/allura/tests/functional/test_user_profile.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 4c6ebcd..fcea8b4 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -1,5 +1,6 @@
 from formencode.variabledecode import variable_encode
 
+from allura.model import Project, User
 from allura.tests import decorators as td
 from allura.tests import TestController
 
@@ -24,6 +25,14 @@ class TestUserProfile(TestController):
         response = self.app.get('/u/test-user/profile/')
         assert 'Email Addresses' not in response
 
+    @td.with_user_project('test-user')
+    def test_missing_user(self):
+        User.query.remove(dict(username='test-user'))
+        p = Project.query.get(shortname='u/test-user')
+        assert p is not None and p.is_user_project
+        response = self.app.get('/u/test-user/profile/', status=404)
+        assert 'Email Addresses' not in response
+
     @td.with_user_project('test-admin')
     @td.with_wiki
     def test_feed(self):


Mime
View raw message