mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #24145 -- Added PUT & PATCH to CommonMiddleware APPEND_SLASH redirect error.
This commit is contained in:
parent
eb4cdfbdd6
commit
5b74134f27
2 changed files with 17 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue