Merge branch 'open338' into rems_data

This commit is contained in:
Henry 2015-12-03 15:28:25 -08:00
commit e16b156d1d
2 changed files with 16 additions and 10 deletions

View File

@ -39,6 +39,7 @@ define(
function CopyTask (domainObject, parent, policyService, $q){
this.domainObject = domainObject;
this.parent = parent;
this.firstClone = undefined;
this.$q = $q;
this.deferred = undefined;
this.policyService = policyService;
@ -97,12 +98,10 @@ define(
* Will add a list of clones to the specified parent's composition
*/
function addClonesToParent(self) {
var parentClone = self.clones[self.clones.length-1];
return parentClone.getCapability("persistence").persist()
.then(function(){self.parent.getCapability("composition").add(parentClone.getId())})
return self.firstClone.getCapability("persistence").persist()
.then(function(){self.parent.getCapability("composition").add(self.firstClone.getId())})
.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;
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;
});
};

View File

@ -390,16 +390,20 @@ define(
});
describe("when cloning non-creatable objects", function() {
beforeEach(function () {
policyService.allow.callFake(function(category, object){
return category === 'creation';
policyService.allow.andCallFake(function(category){
//Return false for 'creation' policy
return category !== 'creation';
});
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
});
it ("creates links", function() {
expect(childObjectClone.getModel().location).toEqual(objectClone.getId());
it ("creates link instead of clone", function() {
var copiedObject = copyFinished.calls[0].args[0];
expect(copiedObject).toBe(object);
expect(compositionCapability.add).toHaveBeenCalledWith(copiedObject.getId());
//expect(newParent.getModel().composition).toContain(copiedObject.getId());
});
});
});