不要怂,就是干,撸起袖子干!

Commit f1b02612 by Robert Kieffer Committed by Sushant

Fix sequelize.transaction() breaks when used with Promise.mapSeries (… (#7416)

* Fix sequelize.transaction() breaks when used with Promise.mapSeries (#5943) (#6319)

* jshint fixes
1 parent 437b8499
Showing with 36 additions and 0 deletions
......@@ -33,10 +33,12 @@ shimCLS(Promise.prototype, 'finally', [0]);
// Collections
shimCLS(Promise, 'map', [1]);
shimCLS(Promise, 'mapSeries', [1]);
shimCLS(Promise, 'reduce', [1]);
shimCLS(Promise, 'filter', [1]);
shimCLS(Promise, 'each', [1]);
shimCLS(Promise.prototype, 'map', [0]);
shimCLS(Promise.prototype, 'mapSeries', [0]);
shimCLS(Promise.prototype, 'reduce', [0]);
shimCLS(Promise.prototype, 'filter', [0]);
shimCLS(Promise.prototype, 'each', [0]);
......
......@@ -256,6 +256,40 @@ if (current.dialect.supports.transactions) {
});
});
it('mapSeries', function () {
var self = this;
return this.sequelize.transaction(function () {
var tid = self.ns.get('transaction').id;
return self.User.findAll().mapSeries(function () {
expect(self.ns.get('transaction').id).to.be.ok;
expect(self.ns.get('transaction').id).to.equal(tid);
});
});
});
it('static mapSeries', function () {
var self = this;
return this.sequelize.transaction(function () {
var tid = self.ns.get('transaction').id;
// In order to execute promises serially with mapSeries we must wrap them as functions
return self.sequelize.Promise.mapSeries(
[
function() {
return self.User.findAll().then(
function() {expect(self.ns.get('transaction').id).to.be.ok;}
);
},
function() {
return self.User.findAll().then(
function() {expect(self.ns.get('transaction').id).to.equal(tid);}
);
}
],
function(runPromise) {return runPromise();}
);
});
});
it('reduce', function () {
var self = this;
return this.sequelize.transaction(function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!