[Persistence] Include timestamp on creation

Include a persisted timestamp when an object is first
created. nasa/openmctweb#139
This commit is contained in:
Victor Woeltjen
2015-09-22 11:32:18 -07:00
parent 8c1b70f085
commit 56ccf29cfe
3 changed files with 15 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ define(
describe("The creation service", function () {
var mockPersistenceService,
mockNow,
mockQ,
mockLog,
mockParentObject,
@@ -63,6 +64,7 @@ define(
"persistenceService",
[ "createObject" ]
);
mockNow = jasmine.createSpy('now');
mockQ = { when: mockPromise, reject: mockReject };
mockLog = jasmine.createSpyObj(
"$log",
@@ -103,6 +105,8 @@ define(
mockPromise(true)
);
mockNow.andReturn(12321);
mockParentObject.getCapability.andCallFake(function (key) {
return mockCapabilities[key];
});
@@ -123,6 +127,7 @@ define(
creationService = new CreationService(
mockPersistenceService,
mockNow,
mockQ,
mockLog
);
@@ -201,6 +206,12 @@ define(
expect(mockLog.error).toHaveBeenCalled();
});
it("attaches a 'persisted' timestamp", function () {
var model = { someKey: "some value" };
creationService.createObject(model, mockParentObject);
expect(model.persisted).toEqual(mockNow());
});
});
}
);