diff --git a/platform/entanglement/src/services/CopyService.js b/platform/entanglement/src/services/CopyService.js index 07fa85741e..b7e10ba9ab 100644 --- a/platform/entanglement/src/services/CopyService.js +++ b/platform/entanglement/src/services/CopyService.js @@ -83,8 +83,8 @@ define( } return policyService.allow( "composition", - object.getCapability('type'), - parentCandidate.getCapability('type') + parentCandidate.getCapability('type'), + object.getCapability('type') ); }, /** diff --git a/platform/entanglement/src/services/LinkService.js b/platform/entanglement/src/services/LinkService.js index e48f0df623..9e570a9e4e 100644 --- a/platform/entanglement/src/services/LinkService.js +++ b/platform/entanglement/src/services/LinkService.js @@ -44,8 +44,8 @@ define( } return policyService.allow( "composition", - object.getCapability('type'), - parentCandidate.getCapability('type') + parentCandidate.getCapability('type'), + object.getCapability('type') ); }, /** diff --git a/platform/entanglement/src/services/MoveService.js b/platform/entanglement/src/services/MoveService.js index ad0bb817e9..206b5916af 100644 --- a/platform/entanglement/src/services/MoveService.js +++ b/platform/entanglement/src/services/MoveService.js @@ -51,8 +51,8 @@ define( } return policyService.allow( "composition", - object.getCapability('type'), - parentCandidate.getCapability('type') + parentCandidate.getCapability('type'), + object.getCapability('type') ); }, /** diff --git a/platform/entanglement/test/services/CopyServiceSpec.js b/platform/entanglement/test/services/CopyServiceSpec.js index cc7780e473..6d7b1d5069 100644 --- a/platform/entanglement/test/services/CopyServiceSpec.js +++ b/platform/entanglement/test/services/CopyServiceSpec.js @@ -60,10 +60,16 @@ define( policyService ); object = domainObjectFactory({ - name: 'object' + name: 'object', + capabilities: { + type: { type: 'object' } + } }); parentCandidate = domainObjectFactory({ - name: 'parentCandidate' + name: 'parentCandidate', + capabilities: { + type: { type: 'parentCandidate' } + } }); validate = function () { return copyService.validate(object, parentCandidate); @@ -88,6 +94,15 @@ define( parentCandidate.id = 'b'; }); + it("calls policy service with correct args", function () { + validate(); + expect(policyService.allow).toHaveBeenCalledWith( + "composition", + parentCandidate.capabilities.type, + object.capabilities.type + ); + }); + it("and returns false", function () { policyService.allow.andReturn(false); expect(validate()).toBe(false); diff --git a/platform/entanglement/test/services/LinkServiceSpec.js b/platform/entanglement/test/services/LinkServiceSpec.js index fc1983585d..0551256277 100644 --- a/platform/entanglement/test/services/LinkServiceSpec.js +++ b/platform/entanglement/test/services/LinkServiceSpec.js @@ -84,10 +84,23 @@ define( describe("defers to policyService", function () { beforeEach(function () { object.id = 'abc'; + object.capabilities.type = { type: 'object' }; parentCandidate.id = 'xyz'; + parentCandidate.capabilities.type = { + type: 'parentCandidate' + }; parentCandidate.model.composition = []; }); + it("calls policy service with correct args", function () { + validate(); + expect(mockPolicyService.allow).toHaveBeenCalledWith( + "composition", + parentCandidate.capabilities.type, + object.capabilities.type + ); + }); + it("and returns false", function () { mockPolicyService.allow.andReturn(true); expect(validate()).toBe(true); diff --git a/platform/entanglement/test/services/MoveServiceSpec.js b/platform/entanglement/test/services/MoveServiceSpec.js index 6d05aa1bab..d1ffb52bc1 100644 --- a/platform/entanglement/test/services/MoveServiceSpec.js +++ b/platform/entanglement/test/services/MoveServiceSpec.js @@ -65,7 +65,8 @@ define( name: 'object', id: 'a', capabilities: { - context: objectContextCapability + context: objectContextCapability, + type: { type: 'object' } } }); @@ -78,8 +79,11 @@ define( parentCandidate = domainObjectFactory({ name: 'parentCandidate', - model: {composition: []}, - id: 'c' + model: { composition: [] }, + id: 'c', + capabilities: { + type: { type: 'parentCandidate' } + } }); validate = function () { @@ -112,6 +116,15 @@ define( describe("defers to policyService", function () { + it("calls policy service with correct args", function () { + validate(); + expect(policyService.allow).toHaveBeenCalledWith( + "composition", + parentCandidate.capabilities.type, + object.capabilities.type + ); + }); + it("and returns false", function () { policyService.allow.andReturn(false); expect(validate()).toBe(false);