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

Commit 2e4363d0 by Sascha Depold

another test for 1:n association prefetching

1 parent 5ca93046
Showing with 24 additions and 0 deletions
......@@ -444,6 +444,30 @@ dialects.forEach(function(dialect) {
}.bind(this)) //- User.create
}.bind(this)) //- sequelize.sync
})
it('fetches associated objects for 1:N associations (2nd direction)', function(done) {
this.User.hasMany(this.Task)
this.Task.belongsTo(this.User)
this.sequelize.sync({ force: true }).success(function() {
this.User.create({ name: 'barfooz' }).success(function(user) {
this.Task.create({ title: 'task1' }).success(function(task1) {
this.Task.create({ title: 'task2' }).success(function(task2) {
user.setTasks([task1, task2]).success(function() {
this.Task.find({
where: { 'Tasks.id': 1 },
include: [ 'UserWithName' ]
}).success(function(task) {
expect(task.userWithName).toBeDefined()
expect(task.userWithName.name).toEqual(user.name)
done()
})
}.bind(this)) //- setTask
}.bind(this)) //- Task.create
}.bind(this)) //- Task.create
}.bind(this)) //- User.create
}.bind(this)) //- sequelize.sync
})
})
}
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!