[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.
This commit is contained in:
Pete Richards 2015-08-19 11:49:03 -07:00
parent 94854e5965
commit 5c74365f4b
2 changed files with 14 additions and 4 deletions

View File

@ -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;
}
);
);

View File

@ -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(
});
}
);
);