return promises correctly, remove stop from queue complete, fix pending test, use sinon autorelease

This commit is contained in:
Joe Fleming 2014-08-22 11:22:48 -07:00
parent b6389b6b15
commit 2da24fc27c
2 changed files with 15 additions and 12 deletions

View file

@ -47,17 +47,19 @@ define(function (require) {
self._setRequestHandlers(opts);
return Promise.try(function () {
self._extractQueue(opts.direction);
return self._extractQueue(opts.direction);
})
.then(function () {
req = self._createRequest();
return req;
})
.then(function (req) {
self._startRequest(req);
return self._startRequest(req);
})
.then(function () {
self._executeRequest(req, opts);
return self._executeRequest(req, opts);
}).then(function () {
return self._stopRequest();
});
};
@ -87,7 +89,9 @@ define(function (require) {
// stop any existing segmentedFetches
if (self.running) {
p = p.then(self._stopRequest);
p = p.then(function () {
self._stopRequest();
});
}
return p.then(function () {
@ -268,12 +272,10 @@ define(function (require) {
};
segmentedFetch.prototype._processQueueComplete = function (req, loopCount) {
return this._stopRequest().then(function () {
req.complete = true;
req.ms = req.moment.diff() * -1;
req.source.activeFetchCount -= 1;
return (loopCount + 1);
});
req.complete = true;
req.ms = req.moment.diff() * -1;
req.source.activeFetchCount -= 1;
return (loopCount + 1);
};
function mergeRequestStats(requestStats, resp) {

View file

@ -1,5 +1,5 @@
define(function (require) {
var sinon = require('sinon/sinon');
var sinon = require('test_utils/auto_release_sinon');
var Promise = require('bluebird');
var SegmentedFetch;
@ -157,10 +157,11 @@ define(function (require) {
it('should abort the existing fetch');
it('should abort the es promise', function () {
});
it('should abort the es promise');
it('should clear the notification', function () {
var spy = segmentedFetch.notifyEvent = sinon.spy();