diff --git a/CHANGES.rst b/CHANGES.rst index 679debbddb..0cfd03520d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,10 @@ Bugfixes: - Make sure DX DefaultFieldDeserializer validates field values. [lgraf] +- Reindex AT content on PATCH. +Fixes `issue 531 `_. +[buchi] + 2.1.0 (2018-06-23) ------------------ @@ -24,6 +28,8 @@ New Features: - Include translated role title in `@roles` GET. [lgraf] + + 2.0.1 (2018-06-22) ------------------ diff --git a/src/plone/restapi/deserializer/atcontent.py b/src/plone/restapi/deserializer/atcontent.py index 390667c0bc..746149075c 100644 --- a/src/plone/restapi/deserializer/atcontent.py +++ b/src/plone/restapi/deserializer/atcontent.py @@ -67,6 +67,7 @@ def __call__(self, validate_all=False, data=None): notify(ObjectInitializedEvent(obj)) obj.at_post_create_script() else: + obj.reindexObject() notify(ObjectEditedEvent(obj)) obj.at_post_edit_script() diff --git a/src/plone/restapi/tests/test_content_patch.py b/src/plone/restapi/tests/test_content_patch.py index a4adbb7108..8a02f17fad 100644 --- a/src/plone/restapi/tests/test_content_patch.py +++ b/src/plone/restapi/tests/test_content_patch.py @@ -8,6 +8,7 @@ from plone.app.testing import TEST_USER_PASSWORD from plone.app.testing import login from plone.app.testing import setRoles +from plone.restapi.testing import PLONE_RESTAPI_AT_FUNCTIONAL_TESTING from plone.restapi.testing import PLONE_RESTAPI_DX_FUNCTIONAL_TESTING import requests @@ -162,3 +163,36 @@ def test_patch_image_with_the_contents_of_the_get_preserves_image(self): self.assertTrue(response.json()['image']) self.assertIn('content-type', response.json()['image']) self.assertIn('download', response.json()['image']) + + +class TestATContentPatch(unittest.TestCase): + + layer = PLONE_RESTAPI_AT_FUNCTIONAL_TESTING + + def setUp(self): + self.app = self.layer['app'] + self.portal = self.layer['portal'] + setRoles(self.portal, TEST_USER_ID, ['Manager']) + login(self.portal, TEST_USER_NAME) + self.portal.portal_repository._versionable_content_types = [] + self.portal.invokeFactory( + 'Document', + id='doc1', + title='My Document', + description='Some Description' + ) + self.portal.doc1.unmarkCreationFlag() + transaction.commit() + + def test_patch_reindexes_document(self): + requests.patch( + self.portal.doc1.absolute_url(), + headers={'Accept': 'application/json'}, + auth=(TEST_USER_NAME, TEST_USER_PASSWORD), + json={ + "description": "Foo Bar", + }, + ) + transaction.begin() + brain = self.portal.portal_catalog(UID=self.portal.doc1.UID())[0] + self.assertEqual(brain.Description, 'Foo Bar')