Merge pull request #1868 from normanjaeckel/TrivialChanges

Enabled the option to disabled version for motion update requests.
This commit is contained in:
Oskar Hahn 2016-01-15 09:31:30 +01:00
commit 4ffbd8be29
3 changed files with 25 additions and 3 deletions

View File

@ -120,7 +120,7 @@ class MotionViewSet(ModelViewSet):
data=request.data,
partial=kwargs.get('partial', False))
serializer.is_valid(raise_exception=True)
updated_motion = serializer.save()
updated_motion = serializer.save(disable_versioning=request.data.get('disable_versioning'))
# Write the log message, check removal of supporters and initiate response.
# TODO: Log if a version was updated.

View File

@ -7,7 +7,7 @@ from rest_framework.test import APIClient
from openslides.core.config import config
from openslides.core.models import Tag
from openslides.motions.models import Category, Motion
from openslides.motions.models import Category, Motion, State
from openslides.utils.test import TestCase
@ -221,6 +221,27 @@ class UpdateMotion(TestCase):
self.assertEqual(motion.title, 'new_title_ohph1aedie5Du8sai2ye')
self.assertEqual(motion.supporters.count(), 0)
def test_with_new_version(self):
self.motion.set_state(State.objects.get(name='permitted'))
self.motion.save()
response = self.client.patch(
reverse('motion-detail', args=[self.motion.pk]),
{'text': 'test_text_aeb1iaghahChong5od3a'})
self.assertEqual(response.status_code, status.HTTP_200_OK)
motion = Motion.objects.get()
self.assertEqual(motion.versions.count(), 2)
def test_without_new_version(self):
self.motion.set_state(State.objects.get(name='permitted'))
self.motion.save()
response = self.client.patch(
reverse('motion-detail', args=[self.motion.pk]),
{'text': 'test_text_aeThaeroneiroo7Iophu',
'disable_versioning': True})
self.assertEqual(response.status_code, status.HTTP_200_OK)
motion = Motion.objects.get()
self.assertEqual(motion.versions.count(), 1)
class ManageVersion(TestCase):
"""

View File

@ -47,8 +47,9 @@ class MotionViewSetUpdate(TestCase):
@patch('openslides.motions.views.config')
def test_simple_update(self, mock_config):
self.request.user.has_perm.return_value = True
self.request.data.get.return_value = versioning_mock = MagicMock()
self.view_instance.update(self.request)
self.mock_serializer.save.assert_called_with()
self.mock_serializer.save.assert_called_with(disable_versioning=versioning_mock)
class MotionViewSetManageVersion(TestCase):