Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #844 from darkwing/querystring-login-777361
Browse files Browse the repository at this point in the history
fix bug 777361 - Keep querystring values when logging in and out
  • Loading branch information
groovecoder committed Feb 7, 2013
2 parents e766b1e + 210fd7e commit 7cab02f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/devmo/context_processors.py
Expand Up @@ -12,5 +12,5 @@ def i18n(request):

def next_url(request):
if 'login' not in request.path and 'register' not in request.path:
return {'next_url': request.path }
return {'next_url': request.get_full_path()}
return {}
27 changes: 27 additions & 0 deletions apps/devmo/tests/test_misc.py
Expand Up @@ -11,6 +11,11 @@
from devmo.helpers import devmo_url
from devmo import urlresolvers

from devmo.context_processors import next_url
from django.core.handlers.wsgi import WSGIRequest
from django.contrib.auth.models import AnonymousUser
from StringIO import StringIO


def parse_robots(base_url):
""" Given a base url, retrieves the robot.txt file and
Expand All @@ -37,6 +42,15 @@ def parse_robots(base_url):
return rules


def _make_request(path):
req = WSGIRequest({
'REQUEST_METHOD': 'GET',
'PATH_INFO': path,
'wsgi.input': StringIO()})
req.user = AnonymousUser()
return req


class TestDevMoRobots(test_utils.TestCase):
""" These are really acceptance tests, but we seem to lump
together unit, integration, regression, and
Expand Down Expand Up @@ -141,3 +155,16 @@ def test_prefixer_get_language(self):
req.META['HTTP_ACCEPT_LANGUAGE'] = 'fr'
prefixer = urlresolvers.Prefixer(req)
eq_(prefixer.get_language(), 'fr')


class TestDevMoNextUrl(test_utils.TestCase):
""" Tests that the next_url value is properly set,
including query string """
def test_basic(self):
path = '/one/two'
eq_(next_url(_make_request(path))['next_url'], path)

def test_querystring(self):
path = '/one/two?something'
req = _make_request(path)
eq_(next_url(_make_request(path))['next_url'], path)

0 comments on commit 7cab02f

Please sign in to comment.