Fix checkout list view
Add tests for the checkout list view. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
||||
import logging
|
||||
|
||||
from mayan.apps.common.literals import TIME_DELTA_UNIT_DAYS
|
||||
from mayan.apps.documents.permissions import permission_document_view
|
||||
from mayan.apps.documents.tests import GenericDocumentViewTestCase
|
||||
from mayan.apps.sources.links import link_upload_version
|
||||
|
||||
@@ -140,6 +141,43 @@ class DocumentCheckoutViewTestCase(DocumentCheckoutTestMixin, GenericDocumentVie
|
||||
response, text=STATE_LABELS[STATE_CHECKED_OUT], status_code=200
|
||||
)
|
||||
|
||||
def _request_check_out_list_view(self):
|
||||
return self.get(viewname='checkouts:check_out_list')
|
||||
|
||||
def test_checkout_list_view_no_permission(self):
|
||||
self._check_out_document()
|
||||
|
||||
self.grant_access(
|
||||
obj=self.document,
|
||||
permission=permission_document_view
|
||||
)
|
||||
|
||||
response = self._request_check_out_list_view()
|
||||
|
||||
self.assertNotContains(
|
||||
response=response, text=self.document.label, status_code=200
|
||||
)
|
||||
|
||||
|
||||
def test_checkout_list_view_with_access(self):
|
||||
self._check_out_document()
|
||||
|
||||
self.grant_access(
|
||||
obj=self.document,
|
||||
permission=permission_document_check_out_detail_view
|
||||
)
|
||||
|
||||
self.grant_access(
|
||||
obj=self.document,
|
||||
permission=permission_document_view
|
||||
)
|
||||
|
||||
response = self._request_check_out_list_view()
|
||||
|
||||
self.assertContains(
|
||||
response=response, text=self.document.label, status_code=200
|
||||
)
|
||||
|
||||
def test_document_new_version_after_check_out(self):
|
||||
"""
|
||||
Gitlab issue #231
|
||||
|
||||
@@ -81,19 +81,19 @@ class CheckoutListView(DocumentListView):
|
||||
{
|
||||
'name': _('User'),
|
||||
'attribute': encapsulate(
|
||||
lambda document: document.check_out_info().user.get_full_name() or document.check_out_info().user
|
||||
lambda document: document.get_check_out_info().user.get_full_name() or document.get_check_out_info().user
|
||||
)
|
||||
},
|
||||
{
|
||||
'name': _('Checkout time and date'),
|
||||
'attribute': encapsulate(
|
||||
lambda document: document.check_out_info().checkout_datetime
|
||||
lambda document: document.get_check_out_info().checkout_datetime
|
||||
)
|
||||
},
|
||||
{
|
||||
'name': _('Checkout expiration'),
|
||||
'attribute': encapsulate(
|
||||
lambda document: document.check_out_info().expiration_datetime
|
||||
lambda document: document.get_check_out_info().expiration_datetime
|
||||
)
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user