Change the way new document version are blocked, moving the logic to the documents app from the checkouts app signal handler. Disable the upload new document version button and have the new version upload view redirect to the document version list with a message. GitLab issue #231.
This commit is contained in:
@@ -16,7 +16,9 @@ from user_management.tests.literals import (
|
||||
)
|
||||
|
||||
from ..literals import DEFAULT_DELETE_PERIOD, DEFAULT_DELETE_TIME_UNIT
|
||||
from ..models import DeletedDocument, Document, DocumentType, HASH_FUNCTION
|
||||
from ..models import (
|
||||
DeletedDocument, Document, DocumentType, NewVersionBlock, HASH_FUNCTION
|
||||
)
|
||||
from ..permissions import (
|
||||
permission_document_download, permission_document_properties_edit,
|
||||
permission_document_restore, permission_document_tools,
|
||||
@@ -575,3 +577,32 @@ class DocumentTypeViewsTestCase(GenericDocumentViewTestCase):
|
||||
DocumentType.objects.get(pk=self.document_type.pk).label,
|
||||
TEST_DOCUMENT_TYPE_EDITED_LABEL
|
||||
)
|
||||
|
||||
|
||||
class NewDocumentVersionBlockViewTestCase(GenericDocumentViewTestCase):
|
||||
def test_document_new_version_after_checkout(self):
|
||||
"""
|
||||
Gitlab issue #231
|
||||
User shown option to upload new version of a document even though it
|
||||
is blocked by checkout - v2.0.0b2
|
||||
|
||||
Expected results:
|
||||
- Link to upload version view should not resolve
|
||||
- Upload version view should reject request
|
||||
"""
|
||||
|
||||
self.login(
|
||||
username=TEST_ADMIN_USERNAME, password=TEST_ADMIN_PASSWORD
|
||||
)
|
||||
|
||||
NewVersionBlock.objects.block(self.document)
|
||||
|
||||
response = self.post(
|
||||
'sources:upload_version', args=(self.document.pk,),
|
||||
follow=True
|
||||
)
|
||||
|
||||
self.assertContains(
|
||||
response, text='blocked from uploading',
|
||||
status_code=200
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user