diff --git a/platform/core/bundle.js b/platform/core/bundle.js index 9ad64d47f9..dfc45299e4 100644 --- a/platform/core/bundle.js +++ b/platform/core/bundle.js @@ -355,7 +355,8 @@ define([ "implementation": InstantiationCapability, "depends": [ "$injector", - "identifierService" + "identifierService", + "now" ] } ], diff --git a/platform/core/src/capabilities/InstantiationCapability.js b/platform/core/src/capabilities/InstantiationCapability.js index 82187a49bd..52e1238cc6 100644 --- a/platform/core/src/capabilities/InstantiationCapability.js +++ b/platform/core/src/capabilities/InstantiationCapability.js @@ -35,10 +35,16 @@ define( * @param $injector Angular's `$injector` * @implements {Capability} */ - function InstantiationCapability($injector, identifierService, domainObject) { + function InstantiationCapability( + $injector, + identifierService, + now, + domainObject + ) { this.$injector = $injector; this.identifierService = identifierService; this.domainObject = domainObject; + this.now = now; } /** @@ -57,6 +63,8 @@ define( space = parsedId.getDefinedSpace(), id = this.identifierService.generate(space); + model.modified = this.now(); + // Lazily initialize; instantiate depends on capabilityService, // which depends on all capabilities, including this one. this.instantiateFn = this.instantiateFn || diff --git a/platform/core/test/capabilities/InstantiationCapabilitySpec.js b/platform/core/test/capabilities/InstantiationCapabilitySpec.js index 35e0530b38..d14ebf8292 100644 --- a/platform/core/test/capabilities/InstantiationCapabilitySpec.js +++ b/platform/core/test/capabilities/InstantiationCapabilitySpec.js @@ -31,6 +31,7 @@ define( mockIdentifierService, mockInstantiate, mockIdentifier, + mockNow, mockDomainObject, instantiation; @@ -57,9 +58,13 @@ define( mockIdentifierService.parse.andReturn(mockIdentifier); mockIdentifierService.generate.andReturn("some-id"); + mockNow = jasmine.createSpy(); + mockNow.andReturn(1234321); + instantiation = new InstantiationCapability( mockInjector, mockIdentifierService, + mockNow, mockDomainObject ); }); @@ -81,7 +86,10 @@ define( expect(instantiation.instantiate(testModel)) .toBe(mockDomainObject); expect(mockInstantiate) - .toHaveBeenCalledWith(testModel, jasmine.any(String)); + .toHaveBeenCalledWith({ + someKey: "some value", + modified: mockNow() + }, jasmine.any(String)); }); });