Fixed #24145 -- Added PUT & PATCH to CommonMiddleware APPEND_SLASH redirect error.

This commit is contained in:
Samuel Colvin 2015-01-13 13:42:21 +00:00 committed by Tim Graham
parent eb4cdfbdd6
commit 5b74134f27
2 changed files with 17 additions and 8 deletions

View file

@ -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)