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

Commit 562c183b by Sascha Gehlich

Added test

1 parent c343301c
Showing with 35 additions and 1 deletions
......@@ -265,7 +265,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
describe.only('addAssociations', function() {
describe('addAssociations', function() {
it('supports transactions', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var Article = sequelize.define('Article', { 'title': DataTypes.STRING })
......@@ -654,6 +654,40 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
describe('addAssociations', function() {
it('supports transactions', function(done) {
var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = self.sequelize.define('User', { username: DataTypes.STRING })
, Task = self.sequelize.define('Task', { title: DataTypes.STRING })
User.hasMany(Task)
Task.hasMany(User)
User.sync({ force: true }).success(function() {
Task.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) {
Task.create({ title: 'task' }).success(function(task) {
self.sequelize.transaction(function(t){
task.addUser(user, { transaction: t }).success(function() {
task.hasUser(user).success(function(hasUser) {
expect(hasUser).to.be.false
task.hasUser(user, { transaction: t }).success(function(hasUser) {
expect(hasUser).to.be.true
t.rollback().success(function() { done() })
})
})
})
})
})
})
})
})
})
})
})
describe('optimizations using bulk create, destroy and update', function () {
beforeEach(function (done) {
var self = this
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!