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

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) { ...@@ -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'); options.transaction = this.sequelize.constructor.cls.get('transaction');
} }
......
...@@ -36,16 +36,21 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -36,16 +36,21 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
it('should use transaction from cls if available', function () { it('should use transaction from cls if available', function () {
var self = this;
current.constructor.cls.run(function () {
current.constructor.cls.set('transaction', { id: 123 });
var options = { var options = {
where : { where : {
name : '123' name : 'John'
} }
}; };
this.User.findOrCreate(options); self.User.findOrCreate(options);
expect(options).to.have.any.keys('transaction'); 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!