workflows: embed non-dictionary trigger data in a dictionary (#76041) #898
|
@ -201,6 +201,18 @@ def test_workflow_trigger_with_data(pub, local_user):
|
|||
params='ERROR',
|
||||
)
|
||||
|
||||
# post with JSON data that is not a dictionary
|
||||
formdata = formdef.data_class()()
|
||||
formdata.just_created()
|
||||
formdata.store()
|
||||
get_app(pub).post_json(
|
||||
sign_uri(formdata.get_url() + 'jump/trigger/xx-yy'),
|
||||
status=200,
|
||||
headers={'content-type': 'application/json'},
|
||||
params=['a', 'b', 'c'],
|
||||
)
|
||||
assert formdef.data_class().get(formdata.id).workflow_data == {'xx-yy': ['a', 'b', 'c']}
|
||||
|
||||
|
||||
def test_workflow_trigger_with_file_data(pub, local_user):
|
||||
workflow = Workflow(name='test')
|
||||
|
|
|
@ -116,6 +116,10 @@ class TriggerDirectory(Directory):
|
|||
self.formdata.evolution[-1].add_part(
|
||||
WorkflowTriggeredEvolutionPart(component, workflow_data, 'jump')
|
||||
)
|
||||
if workflow_data is not None and not isinstance(workflow_data, dict):
|
||||
# for historical reason dictionaries are stored as-is, other data
|
||||
# types are embedded in a new dictionary.
|
||||
workflow_data = {component: workflow_data}
|
||||
self.formdata.store()
|
||||
self.formdata.record_workflow_event('api-trigger', action_item_id=item.id)
|
||||
url = jump_and_perform(self.formdata, item, workflow_data=workflow_data)
|
||||
|
|
Loading…
Reference in New Issue