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

Commit 9cfa725f by Javier Cornejo

Add test for more than one model per transaction

1 parent bf3a38e9
Showing with 17 additions and 1 deletions
...@@ -28,8 +28,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -28,8 +28,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
aBool: DataTypes.BOOLEAN, aBool: DataTypes.BOOLEAN,
uniqueName: { type: DataTypes.STRING, unique: true } uniqueName: { type: DataTypes.STRING, unique: true }
}) })
this.Account = this.sequelize.define('Account', {
accountName: DataTypes.STRING
});
return this.User.sync({ force: true }); return this.sequelize.sync({ force: true });
}); });
}); });
...@@ -51,6 +54,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -51,6 +54,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it("supports more than one models per transaction", function(done) {
var self = this;
this.sequelize.transaction().then(function(t) {
self.User.findOrCreate({ where: { username: 'Username'}, defaults: { data: 'some data' }}, { transaction: t }).then(function() {
self.Account.findOrCreate({ where: { accountName: 'accountName'}}, { transaction: t}).then(function(){
t.commit().success(function() {
done()
})
})
})
})
})
it("returns instance if already existent. Single find field.", function(done) { it("returns instance if already existent. Single find field.", function(done) {
var self = this, var self = this,
data = { data = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!