mirror of
https://github.com/nasa/openmct.git
synced 2025-01-02 03:16:41 +00:00
Merge branch 'open1071' into open-master
Merge changes for WTD-1071
This commit is contained in:
commit
3707a68ea1
@ -51,6 +51,11 @@ define(
|
|||||||
// some special behavior for its context capability.
|
// some special behavior for its context capability.
|
||||||
root = root || domainObject;
|
root = root || domainObject;
|
||||||
|
|
||||||
|
// Avoid double-wrapping (WTD-1017)
|
||||||
|
if (domainObject.hasCapability('editor')) {
|
||||||
|
return domainObject;
|
||||||
|
}
|
||||||
|
|
||||||
// Provide an editable form of the object
|
// Provide an editable form of the object
|
||||||
return new EditableDomainObject(
|
return new EditableDomainObject(
|
||||||
domainObject,
|
domainObject,
|
||||||
|
@ -25,7 +25,7 @@ define(
|
|||||||
);
|
);
|
||||||
mockObject = jasmine.createSpyObj(
|
mockObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getModel", "getCapability" ]
|
[ "getId", "getModel", "getCapability", "hasCapability" ]
|
||||||
);
|
);
|
||||||
mockCapability = jasmine.createSpyObj(
|
mockCapability = jasmine.createSpyObj(
|
||||||
"capability",
|
"capability",
|
||||||
|
@ -21,6 +21,9 @@ define(
|
|||||||
getModel: function () { return {}; },
|
getModel: function () { return {}; },
|
||||||
getCapability: function (name) {
|
getCapability: function (name) {
|
||||||
return completionCapability;
|
return completionCapability;
|
||||||
|
},
|
||||||
|
hasCapability: function (name) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -29,6 +32,9 @@ define(
|
|||||||
var result = Object.create(domainObject);
|
var result = Object.create(domainObject);
|
||||||
result.wrapped = true;
|
result.wrapped = true;
|
||||||
result.wrappedModel = model;
|
result.wrappedModel = model;
|
||||||
|
result.hasCapability = function (name) {
|
||||||
|
return name === 'editor';
|
||||||
|
};
|
||||||
captured.wraps = (captured.wraps || 0) + 1;
|
captured.wraps = (captured.wraps || 0) + 1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -112,6 +118,19 @@ define(
|
|||||||
expect(cache.isRoot(domainObjects[2])).toBeFalsy();
|
expect(cache.isRoot(domainObjects[2])).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not double-wrap objects", function () {
|
||||||
|
var domainObject = new TestObject('test-id'),
|
||||||
|
wrappedObject = cache.getEditableObject(domainObject);
|
||||||
|
|
||||||
|
// Same instance should be returned if you try to wrap
|
||||||
|
// twice. This is necessary, since it's possible to (e.g.)
|
||||||
|
// use a context capability on an object retrieved via
|
||||||
|
// composition, in which case a result will already be
|
||||||
|
// wrapped.
|
||||||
|
expect(cache.getEditableObject(wrappedObject))
|
||||||
|
.toBe(wrappedObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user