Commit 55fd1db4 authored by Jérome Perrin's avatar Jérome Perrin

officejs_support_request: create web message with the post owner as source

.. not the current logged in user.
This way, it's possible to run the post ingestion as another user, for example
running by an alarm or as a data migration.
parent 1b94a641
......@@ -25,7 +25,7 @@ if not resource:
resource = portal.portal_preferences.getPreferredEventResource()
assert resource, "No resource configured for event"
source_value = portal.portal_membership.getAuthenticatedMember().getUserValue()
source_value = portal.Base_getUserValueByUserId(context.getOwnerInfo()['id'])
if source_value is None:
# try harder to get a source for non-person users.
source_value = support_request.getSourceSectionValue()
......
......@@ -430,3 +430,31 @@ class TestSupportRequestRSS(SupportRequestTestCase):
'%s://%s' % (parsed_url.scheme, parsed_url.netloc), '', 1)
# and check it (this time the request is not basic-authenticated)
self._checkRSS(self.publish(restricted_access_url))
class TestIngestPostAsWebMessage(SupportRequestTestCase):
"""Tests ingesting HTML Post into web messages.
"""
def test_Post_ingestMailMessageForSupportRequest_as_other_user(self):
"""Post_ingestMailMessageForSupportRequest should be able to ingest an HTML
Post created by another user, so that we can run int in an alarm for example.
"""
support_request = self.portal.support_request_module.erp5_officejs_support_request_ui_test_support_reuqest_001
# the owner of this post is self.user
post = self.portal.post_module.newContent(
portal_type='HTML Post',
follow_up_value=support_request,
data="Hello"
)
post.publish()
self.tic()
manager_user_id = 'ERP5TypeTestCase'
self.login(manager_user_id)
post.Post_ingestMailMessageForSupportRequest(
web_site_relative_url=self.getWebSite().getRelativeUrl())
self.tic()
web_message, = post.getAggregateRelatedValueList()
self.assertEqual(self.user, web_message.getSourceValue())
self.assertEqual(manager_user_id, web_message.getOwnerInfo()['id'])
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment