mirror of
https://github.com/Hopiu/django-tos.git
synced 2026-03-16 20:10:24 +00:00
Change how middleware tests for is_ajax
This commit is contained in:
parent
eb863621ff
commit
bae4684bdf
2 changed files with 4 additions and 4 deletions
|
|
@ -25,7 +25,7 @@ class UserAgreementMiddleware(MiddlewareMixin):
|
|||
return None
|
||||
|
||||
# Ignore ajax requests
|
||||
if request.is_ajax():
|
||||
if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest':
|
||||
return None
|
||||
|
||||
# Don't redirect users when they're trying to get to the confirm page
|
||||
|
|
|
|||
|
|
@ -111,9 +111,6 @@ class TestMiddleware(TestCase):
|
|||
|
||||
|
||||
@modify_settings(
|
||||
MIDDLEWARE_CLASSES={
|
||||
'append': 'tos.middleware.UserAgreementMiddleware',
|
||||
},
|
||||
MIDDLEWARE={
|
||||
'append': 'tos.middleware.UserAgreementMiddleware',
|
||||
},
|
||||
|
|
@ -142,6 +139,9 @@ class BumpCoverage(TestCase):
|
|||
def test_ajax_request(self):
|
||||
class Request(object):
|
||||
method = 'GET'
|
||||
META = {
|
||||
'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'
|
||||
}
|
||||
|
||||
def is_ajax(self):
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in a new issue