diff --git a/openslides/motions/views.py b/openslides/motions/views.py index f7ce59bc6..27d582982 100644 --- a/openslides/motions/views.py +++ b/openslides/motions/views.py @@ -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. diff --git a/tests/integration/motions/test_viewset.py b/tests/integration/motions/test_viewset.py index 5136d5385..3f2abff4d 100644 --- a/tests/integration/motions/test_viewset.py +++ b/tests/integration/motions/test_viewset.py @@ -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): """ diff --git a/tests/unit/motions/test_views.py b/tests/unit/motions/test_views.py index 08966e426..4687d5f1c 100644 --- a/tests/unit/motions/test_views.py +++ b/tests/unit/motions/test_views.py @@ -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):