Remove workarounds for bad request method checking

Previously, the POST data could not be empty for some views, otherwise
they would not work. This caused the workarounds to be necessary. The
request method detection was fixed in the previous commit, so this
commit removes the workarounds.
pull/2424/merge
Tim Heap 2016-03-31 13:23:39 +11:00 zatwierdzone przez Karl Hobley
rodzic 7fa340f54b
commit c038185915
5 zmienionych plików z 9 dodań i 20 usunięć

Wyświetl plik

@ -332,10 +332,7 @@ class TestSearchPromotionsDeleteView(TestCase, WagtailTestUtils):
def test_post(self):
# Submit
post_data = {
'foo': 'bar',
}
response = self.client.post(reverse('wagtailsearchpromotions:delete', args=(self.query.id, )), post_data)
response = self.client.post(reverse('wagtailsearchpromotions:delete', args=(self.query.id, )))
# User should be redirected back to the index
self.assertRedirects(response, reverse('wagtailsearchpromotions:index'))

Wyświetl plik

@ -361,10 +361,7 @@ class TestDocumentDeleteView(TestCase, WagtailTestUtils):
def test_delete(self):
# Submit title change
post_data = {
'foo': 'bar'
}
response = self.client.post(reverse('wagtaildocs:delete', args=(self.document.id,)), post_data)
response = self.client.post(reverse('wagtaildocs:delete', args=(self.document.id,)))
# User should be redirected back to the index
self.assertRedirects(response, reverse('wagtaildocs:index'))
@ -501,7 +498,7 @@ class TestMultipleDocumentUploader(TestCase, WagtailTestUtils):
"""
This tests that only AJAX requests are allowed to POST to the add view
"""
response = self.client.post(reverse('wagtaildocs:add_multiple'), {})
response = self.client.post(reverse('wagtaildocs:add_multiple'))
# Check response
self.assertEqual(response.status_code, 400)
@ -510,7 +507,7 @@ class TestMultipleDocumentUploader(TestCase, WagtailTestUtils):
"""
This tests that the add view checks for a file when a user POSTs to it
"""
response = self.client.post(reverse('wagtaildocs:add_multiple'), {}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
response = self.client.post(reverse('wagtaildocs:add_multiple'), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# Check response
self.assertEqual(response.status_code, 400)

Wyświetl plik

@ -369,9 +369,7 @@ class TestImageDeleteView(TestCase, WagtailTestUtils):
self.assertTemplateUsed(response, 'wagtailimages/images/confirm_delete.html')
def test_delete(self):
response = self.post({
'hello': 'world'
})
response = self.post()
# Should redirect back to index
self.assertRedirects(response, reverse('wagtailimages:index'))

Wyświetl plik

@ -386,10 +386,10 @@ class TestRedirectsDeleteView(TestCase, WagtailTestUtils):
def get(self, params={}, redirect_id=None):
return self.client.get(reverse('wagtailredirects:delete', args=(redirect_id or self.redirect.id, )), params)
def post(self, post_data={}, redirect_id=None):
def post(self, redirect_id=None):
return self.client.post(reverse(
'wagtailredirects:delete', args=(redirect_id or self.redirect.id, )
), post_data)
))
def test_simple(self):
response = self.get()
@ -400,9 +400,7 @@ class TestRedirectsDeleteView(TestCase, WagtailTestUtils):
self.assertEqual(self.get(redirect_id=100000).status_code, 404)
def test_delete(self):
response = self.post({
'hello': 'world'
})
response = self.post()
# Should redirect back to index
self.assertRedirects(response, reverse('wagtailredirects:index'))

Wyświetl plik

@ -263,9 +263,8 @@ class TestSnippetDelete(TestCase, WagtailTestUtils):
self.assertEqual(response.status_code, 200)
def test_delete_post(self):
post_data = {'foo': 'bar'} # For some reason, this test doesn't work without a bit of POST data
response = self.client.post(
reverse('wagtailsnippets:delete', args=('tests', 'advert', self.test_snippet.id, )), post_data
reverse('wagtailsnippets:delete', args=('tests', 'advert', self.test_snippet.id, ))
)
# Should be redirected to explorer page