Merge pull request #374 from nasa/open305

[Edit] Return a promise from editable persistence capability
This commit is contained in:
akhenry
2015-12-04 12:44:08 -08:00
3 changed files with 9 additions and 1 deletions

View File

@@ -50,7 +50,7 @@ define(
// Simply trigger refresh of in-view objects; do not // Simply trigger refresh of in-view objects; do not
// write anything to database. // write anything to database.
persistence.persist = function () { persistence.persist = function () {
cache.markDirty(editableObject); return cache.markDirty(editableObject);
}; };
// Delegate refresh to the original object; this avoids refreshing // Delegate refresh to the original object; this avoids refreshing

View File

@@ -111,6 +111,7 @@ define(
*/ */
EditableDomainObjectCache.prototype.markDirty = function (domainObject) { EditableDomainObjectCache.prototype.markDirty = function (domainObject) {
this.dirtyObjects[domainObject.getId()] = domainObject; this.dirtyObjects[domainObject.getId()] = domainObject;
return this.$q.when(true);
}; };
/** /**

View File

@@ -31,6 +31,7 @@ define(
mockEditableObject, mockEditableObject,
mockDomainObject, mockDomainObject,
mockCache, mockCache,
mockPromise,
capability; capability;
beforeEach(function () { beforeEach(function () {
@@ -50,7 +51,9 @@ define(
"cache", "cache",
[ "markDirty" ] [ "markDirty" ]
); );
mockPromise = jasmine.createSpyObj("promise", ["then"]);
mockCache.markDirty.andReturn(mockPromise);
mockDomainObject.getCapability.andReturn(mockPersistence); mockDomainObject.getCapability.andReturn(mockPersistence);
capability = new EditablePersistenceCapability( capability = new EditablePersistenceCapability(
@@ -84,6 +87,10 @@ define(
expect(mockPersistence.refresh).toHaveBeenCalled(); expect(mockPersistence.refresh).toHaveBeenCalled();
}); });
it("returns a promise from persist", function () {
expect(capability.persist().then).toEqual(jasmine.any(Function));
});
}); });
} }
); );