Merge pull request #955 from alFReD-NSH/checkpoint-leak
Fix Change.getCheckpointModel() giving new models each call
This commit is contained in:
commit
270dfc2603
|
@ -419,7 +419,7 @@ module.exports = function(Change) {
|
|||
Change.getCheckpointModel = function() {
|
||||
var checkpointModel = this.Checkpoint;
|
||||
if (checkpointModel) return checkpointModel;
|
||||
this.checkpoint = checkpointModel = loopback.Checkpoint.extend('checkpoint');
|
||||
this.Checkpoint = checkpointModel = loopback.Checkpoint.extend('checkpoint');
|
||||
assert(this.dataSource, 'Cannot getCheckpointModel(): ' + this.modelName
|
||||
+ ' is not attached to a dataSource');
|
||||
checkpointModel.attachTo(this.dataSource);
|
||||
|
|
|
@ -28,6 +28,12 @@ describe('Change', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Change.getCheckpointModel()', function() {
|
||||
it('Shouldnt create two models if called twice', function() {
|
||||
assert.equal(Change.getCheckpointModel(), Change.getCheckpointModel());
|
||||
});
|
||||
});
|
||||
|
||||
describe('change.id', function() {
|
||||
it('should be a hash of the modelName and modelId', function() {
|
||||
var change = new Change({
|
||||
|
|
Loading…
Reference in New Issue