From 5c74365f4bb0958007e6c726d852c6ac747f144f Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Wed, 19 Aug 2015 11:49:03 -0700 Subject: [PATCH] [Root] Root model provider sets location Root model provider sets the location of roods so that the location capability does not need special handling for this. --- platform/core/src/models/RootModelProvider.js | 10 +++++++--- platform/core/test/models/RootModelProviderSpec.js | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/platform/core/src/models/RootModelProvider.js b/platform/core/src/models/RootModelProvider.js index 804537ccf2..d3f64c5e36 100644 --- a/platform/core/src/models/RootModelProvider.js +++ b/platform/core/src/models/RootModelProvider.js @@ -42,8 +42,12 @@ define( * @constructor */ function RootModelProvider(roots, $q, $log) { - // Pull out identifiers to used as ROOT's - var ids = roots.map(function (root) { return root.id; }), + // Pull out identifiers to used as ROOT's, while setting locations. + var ids = roots.map(function (root) { + if (!root.model) root.model = {}; + root.model.location = 'ROOT'; + return root.id; + }), baseProvider = new StaticModelProvider(roots, $q, $log); function addRoot(models) { @@ -77,4 +81,4 @@ define( return RootModelProvider; } -); \ No newline at end of file +); diff --git a/platform/core/test/models/RootModelProviderSpec.js b/platform/core/test/models/RootModelProviderSpec.js index 897b38656e..3de505a6cd 100644 --- a/platform/core/test/models/RootModelProviderSpec.js +++ b/platform/core/test/models/RootModelProviderSpec.js @@ -79,6 +79,12 @@ define( expect(captured.b.someProperty).toEqual("Some Value B"); }); + it("provides models with a location", function () { + provider.getModels(["a", "b"]).then(capture); + expect(captured.a.location).toBe('ROOT'); + expect(captured.b.location).toBe('ROOT'); + }); + it("does not provide models which are not in extension declarations", function () { provider.getModels(["c"]).then(capture); @@ -96,4 +102,4 @@ define( }); } -); \ No newline at end of file +);