mirror of
https://github.com/nasa/openmct.git
synced 2024-12-27 08:32:28 +00:00
Merge branch 'open338' into rems_data
This commit is contained in:
commit
e16b156d1d
@ -39,6 +39,7 @@ define(
|
|||||||
function CopyTask (domainObject, parent, policyService, $q){
|
function CopyTask (domainObject, parent, policyService, $q){
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.firstClone = undefined;
|
||||||
this.$q = $q;
|
this.$q = $q;
|
||||||
this.deferred = undefined;
|
this.deferred = undefined;
|
||||||
this.policyService = policyService;
|
this.policyService = policyService;
|
||||||
@ -97,12 +98,10 @@ define(
|
|||||||
* Will add a list of clones to the specified parent's composition
|
* Will add a list of clones to the specified parent's composition
|
||||||
*/
|
*/
|
||||||
function addClonesToParent(self) {
|
function addClonesToParent(self) {
|
||||||
var parentClone = self.clones[self.clones.length-1];
|
return self.firstClone.getCapability("persistence").persist()
|
||||||
|
.then(function(){self.parent.getCapability("composition").add(self.firstClone.getId())})
|
||||||
return parentClone.getCapability("persistence").persist()
|
|
||||||
.then(function(){self.parent.getCapability("composition").add(parentClone.getId())})
|
|
||||||
.then(function(){return self.parent.getCapability("persistence").persist();})
|
.then(function(){return self.parent.getCapability("persistence").persist();})
|
||||||
.then(function(){return parentClone;});
|
.then(function(){return self.firstClone;});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,7 +187,10 @@ define(
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
return this.copy(self.domainObject, self.parent).then(function(domainObjectClone){
|
return this.copy(self.domainObject, self.parent).then(function(domainObjectClone){
|
||||||
domainObjectClone.getModel().location = self.parent.getId();
|
if (domainObjectClone !== self.domainObject) {
|
||||||
|
domainObjectClone.getModel().location = self.parent.getId();
|
||||||
|
}
|
||||||
|
self.firstClone = domainObjectClone;
|
||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -390,16 +390,20 @@ define(
|
|||||||
});
|
});
|
||||||
describe("when cloning non-creatable objects", function() {
|
describe("when cloning non-creatable objects", function() {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
policyService.allow.callFake(function(category, object){
|
policyService.allow.andCallFake(function(category){
|
||||||
return category === 'creation';
|
//Return false for 'creation' policy
|
||||||
|
return category !== 'creation';
|
||||||
});
|
});
|
||||||
|
|
||||||
copyResult = copyService.perform(object, newParent);
|
copyResult = copyService.perform(object, newParent);
|
||||||
copyFinished = jasmine.createSpy('copyFinished');
|
copyFinished = jasmine.createSpy('copyFinished');
|
||||||
copyResult.then(copyFinished);
|
copyResult.then(copyFinished);
|
||||||
});
|
});
|
||||||
it ("creates links", function() {
|
it ("creates link instead of clone", function() {
|
||||||
expect(childObjectClone.getModel().location).toEqual(objectClone.getId());
|
var copiedObject = copyFinished.calls[0].args[0];
|
||||||
|
expect(copiedObject).toBe(object);
|
||||||
|
expect(compositionCapability.add).toHaveBeenCalledWith(copiedObject.getId());
|
||||||
|
//expect(newParent.getModel().composition).toContain(copiedObject.getId());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user