Commit 25eb9448 authored by Julien Muchembled's avatar Julien Muchembled

When executing a workflow method, raise if the transition does not exist from...

When executing a workflow method, raise if the transition does not exist from the current state, or if the guard rejects it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27964 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 21063c59
...@@ -207,8 +207,9 @@ class WorkflowMethod(Method): ...@@ -207,8 +207,9 @@ class WorkflowMethod(Method):
if candidate_workflow.isWorkflowMethodSupported(instance, transition_id): if candidate_workflow.isWorkflowMethodSupported(instance, transition_id):
valid_list.append(transition_id) valid_list.append(transition_id)
elif candidate_workflow.__class__.__name__ == 'DCWorkflowDefinition': elif candidate_workflow.__class__.__name__ == 'DCWorkflowDefinition':
# XXX Do not raise for the moment as ERP5 is not ready. raise UnsupportedWorkflowMethod(instance, wf_id, transition_id)
#raise UnsupportedWorkflowMethod(instance, wf_id, transition_id) # XXX Keep the log for projects that needs to comment out
# the previous line.
LOG("WorkflowMethod.__call__", ERROR, LOG("WorkflowMethod.__call__", ERROR,
"Transition %s/%s on %r is ignored. Current state is %r." "Transition %s/%s on %r is ignored. Current state is %r."
% (wf_id, transition_id, instance, % (wf_id, transition_id, instance,
......
...@@ -38,6 +38,7 @@ from Products.ERP5Type.tests.utils import DummyLocalizer ...@@ -38,6 +38,7 @@ from Products.ERP5Type.tests.utils import DummyLocalizer
from zLOG import LOG, INFO from zLOG import LOG, INFO
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.CMFCore.tests.base.testcase import LogInterceptor from Products.CMFCore.tests.base.testcase import LogInterceptor
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.Base import _aq_reset from Products.ERP5Type.Base import _aq_reset
from Products.ERP5Type.tests.utils import installRealClassTool from Products.ERP5Type.tests.utils import installRealClassTool
from Products.ERP5Type.Utils import removeLocalPropertySheet from Products.ERP5Type.Utils import removeLocalPropertySheet
...@@ -2613,6 +2614,15 @@ class TestPropertySheet: ...@@ -2613,6 +2614,15 @@ class TestPropertySheet:
address.manage_permission(permission, roles=(), acquire=0) address.manage_permission(permission, roles=(), acquire=0)
check(0) check(0)
def test_unsupportedTransitionRaises(self):
"""
Check that an object must be in the expected state in order to execute
a transition.
"""
person = self.getPersonModule().newContent(portal_type='Person')
person.validate()
self.assertRaises(WorkflowException, person.validate)
class TestAccessControl(ERP5TypeTestCase): class TestAccessControl(ERP5TypeTestCase):
# Isolate test in a dedicaced class in order not to break other tests # Isolate test in a dedicaced class in order not to break other tests
# when this one fails. # when this one fails.
......
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