From 374c7d7f18c5fdd1216d8e3c1297f791eec8d0c2 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 28 Aug 2018 16:02:49 +0200 Subject: [PATCH] fix(rules): correct bpmn:Lane insert rule Closes #855 --- lib/features/rules/BpmnRules.js | 4 +++ .../features/rules/BpmnRules.moveLane.bpmn | 25 +++++++++++++++++ test/spec/features/rules/BpmnRulesSpec.js | 28 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 test/spec/features/rules/BpmnRules.moveLane.bpmn diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index 6164702a..cf618af5 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -803,6 +803,10 @@ function canConnectDataAssociation(source, target) { function canInsert(shape, flow, position) { + if (!flow) { + return false; + } + if (Array.isArray(shape)) { if (shape.length !== 1) { return false; diff --git a/test/spec/features/rules/BpmnRules.moveLane.bpmn b/test/spec/features/rules/BpmnRules.moveLane.bpmn new file mode 100644 index 00000000..a611a111 --- /dev/null +++ b/test/spec/features/rules/BpmnRules.moveLane.bpmn @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/features/rules/BpmnRulesSpec.js b/test/spec/features/rules/BpmnRulesSpec.js index dc3eb06c..1d5e184b 100644 --- a/test/spec/features/rules/BpmnRulesSpec.js +++ b/test/spec/features/rules/BpmnRulesSpec.js @@ -1666,4 +1666,32 @@ describe('features/modeling/rules - BpmnRules', function() { }); + + describe('integration', function() { + + describe('move Lane', function() { + + var testXML = require('./BpmnRules.moveLane.bpmn'); + + beforeEach(bootstrapModeler(testXML, { modules: testModules })); + + + it('should disallow', inject(function(elementRegistry, rules) { + + // given + var lane = elementRegistry.get('Lane_1'); + + // when + var result = rules.allowed('elements.move', { + shapes: [ lane ] + }); + + // then + expect(result).to.be.false; + })); + + }); + + }); + });