Fix document type change view

Closes GitLab issue #614. Thanks to Christoph Roeder (@brightdroid)
for the report.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-06-18 22:15:13 -04:00
parent 43260b87c5
commit c3b1c4e173
6 changed files with 143 additions and 6 deletions
+7 -1
View File
@@ -154,7 +154,13 @@ class DocumentViewTestMixin(object):
def _request_test_document_list_view(self):
return self.get(viewname='documents:document_list')
def _request_test_document_type_edit_view(self, document_type):
def _request_test_document_type_edit_get_view(self):
return self.get(
viewname='documents:document_document_type_edit',
kwargs={'pk': self.test_document.pk}
)
def _request_test_document_type_edit_post_view(self, document_type):
return self.post(
viewname='documents:document_document_type_edit',
kwargs={'pk': self.test_document.pk},
@@ -53,7 +53,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
response=response, text=self.test_document.label, status_code=200
)
def test_document_document_type_change_view_no_permissions(self):
def test_document_document_type_change_post_view_no_permissions(self):
self.assertEqual(
self.test_document.document_type, self.test_document_type
)
@@ -62,7 +62,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
label=TEST_DOCUMENT_TYPE_2_LABEL
)
response = self._request_test_document_type_edit_view(
response = self._request_test_document_type_edit_post_view(
document_type=document_type_2
)
self.assertEqual(response.status_code, 404)
@@ -72,7 +72,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
self.test_document_type
)
def test_document_document_type_change_view_with_permissions(self):
def test_document_document_type_change_post_view_with_permissions(self):
self.assertEqual(
self.test_document.document_type, self.test_document_type
)
@@ -88,7 +88,7 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
obj=document_type_2, permission=permission_document_create
)
response = self._request_test_document_type_edit_view(
response = self._request_test_document_type_edit_post_view(
document_type=document_type_2
)
self.assertEqual(response.status_code, 302)
@@ -98,6 +98,29 @@ class DocumentsViewsTestCase(DocumentViewTestMixin, GenericDocumentViewTestCase)
document_type_2
)
def test_document_document_type_change_view_get_no_permissions(self):
response = self._request_test_document_type_edit_get_view(
)
self.assertEqual(response.status_code, 404)
self.assertEqual(
Document.objects.get(pk=self.test_document.pk).document_type,
self.test_document_type
)
def test_document_document_type_change_view_get_with_permissions(self):
self.grant_access(
obj=self.test_document, permission=permission_document_properties_edit
)
response = self._request_test_document_type_edit_get_view(
)
self.assertEqual(response.status_code, 200)
self.assertEqual(
Document.objects.get(pk=self.test_document.pk).document_type,
self.test_document_type
)
def test_document_multiple_document_type_change_view_no_permission(self):
self.assertEqual(
Document.objects.first().document_type, self.test_document_type
+1 -1
View File
@@ -117,7 +117,7 @@ class DocumentDocumentTypeEditView(MultipleObjectFormActionView):
'submit_label': _('Change'),
'title': ungettext(
singular='Change the type of the selected document',
plurals='Change the type of the selected documents',
plural='Change the type of the selected documents',
number=queryset.count()
)
}