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

Commit 14da0d26 by joao.bortolozzo

Test assert against fake transaction object and extra check on options parameter

1 parent feebfae8
......@@ -1641,7 +1641,7 @@ Model.prototype.findOrCreate = function(options) {
);
}
if (this.sequelize.constructor.cls) {
if (options.transaction === undefined && this.sequelize.constructor.cls) {
options.transaction = this.sequelize.constructor.cls.get('transaction');
}
......
......@@ -3,8 +3,8 @@
/* jshint -W030 */
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, current = Support.sequelize
, Support = require(__dirname + '/../support')
, current = Support.sequelize
, cls = require('continuation-local-storage')
, sinon = require('sinon')
, stub = sinon.stub
......@@ -36,16 +36,21 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should use transaction from cls if available', function () {
var self = this;
var options = {
where : {
name : '123'
}
};
current.constructor.cls.run(function () {
current.constructor.cls.set('transaction', { id: 123 });
this.User.findOrCreate(options);
var options = {
where : {
name : 'John'
}
};
expect(options).to.have.any.keys('transaction');
self.User.findOrCreate(options);
expect(options.transaction).to.have.property('id', 123);
});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!