mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24145 -- Added PUT & PATCH to CommonMiddleware APPEND_SLASH redirect error.
This commit is contained in:
committed by
Tim Graham
parent
eb4cdfbdd6
commit
5b74134f27
@@ -68,12 +68,21 @@ class CommonMiddlewareTest(TestCase):
|
||||
def test_append_slash_no_redirect_on_POST_in_DEBUG(self):
|
||||
"""
|
||||
Tests that while in debug mode, an exception is raised with a warning
|
||||
when a failed attempt is made to POST to an URL which would normally be
|
||||
redirected to a slashed version.
|
||||
when a failed attempt is made to POST, PUT, or PATCH to an URL which
|
||||
would normally be redirected to a slashed version.
|
||||
"""
|
||||
msg = "maintaining %s data. Change your form to point to testserver/slash/"
|
||||
request = self.rf.get('/slash')
|
||||
request.method = 'POST'
|
||||
with six.assertRaisesRegex(self, RuntimeError, 'end in a slash'):
|
||||
with six.assertRaisesRegex(self, RuntimeError, msg % request.method):
|
||||
CommonMiddleware().process_request(request)
|
||||
request = self.rf.get('/slash')
|
||||
request.method = 'PUT'
|
||||
with six.assertRaisesRegex(self, RuntimeError, msg % request.method):
|
||||
CommonMiddleware().process_request(request)
|
||||
request = self.rf.get('/slash')
|
||||
request.method = 'PATCH'
|
||||
with six.assertRaisesRegex(self, RuntimeError, msg % request.method):
|
||||
CommonMiddleware().process_request(request)
|
||||
|
||||
@override_settings(APPEND_SLASH=False)
|
||||
|
||||
Reference in New Issue
Block a user