From 1fb18c7919017c1f2a25fc9f371912a271eb6597 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 14 Jul 2016 11:16:07 -0700 Subject: [PATCH] [Context] Add test, tweak logic Add test to verify that warnings are not shown based on composition/location inconsistencies when editing. --- platform/core/src/services/Contextualize.js | 2 +- platform/core/test/services/ContextualizeSpec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/core/src/services/Contextualize.js b/platform/core/src/services/Contextualize.js index 9883c7af15..ff4571782a 100644 --- a/platform/core/src/services/Contextualize.js +++ b/platform/core/src/services/Contextualize.js @@ -68,7 +68,7 @@ define( // Don't validate while editing; consistency is not // necessarily expected due to unsaved changes. var editor = domainObject.getCapability('editor'); - if (editor && !editor.inEditContext()) { + if (!editor || !editor.inEditContext()) { validate(domainObject.getId(), parentObject); } diff --git a/platform/core/test/services/ContextualizeSpec.js b/platform/core/test/services/ContextualizeSpec.js index afaaa4e80e..64f929f217 100644 --- a/platform/core/test/services/ContextualizeSpec.js +++ b/platform/core/test/services/ContextualizeSpec.js @@ -36,6 +36,7 @@ define( var mockLog, mockDomainObject, mockParentObject, + mockEditor, testParentModel, contextualize; @@ -52,11 +53,19 @@ define( mockParentObject = jasmine.createSpyObj('parentObject', DOMAIN_OBJECT_METHODS); + mockEditor = + jasmine.createSpyObj('editor', ['inEditContext']); + mockDomainObject.getId.andReturn("abc"); mockDomainObject.getModel.andReturn({}); mockParentObject.getId.andReturn("parent"); mockParentObject.getModel.andReturn(testParentModel); + mockEditor.inEditContext.andReturn(false); + mockDomainObject.getCapability.andCallFake(function (c) { + return c === 'editor' && mockEditor; + }); + contextualize = new Contextualize(mockLog); }); @@ -82,6 +91,12 @@ define( expect(mockLog.warn).toHaveBeenCalled(); }); + it("does not issue warnings for objects being edited", function () { + mockEditor.inEditContext.andReturn(true); + testParentModel.composition = ["xyz"]; + contextualize(mockDomainObject, mockParentObject); + expect(mockLog.warn).not.toHaveBeenCalled(); + }); }); }