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

Commit fc78f31b by Sushant

(test) fixed the findAndCountAll test

* Used correct ids generated by created records to prevent Fk-Pk issues
1 parent 018a8499
Showing with 19 additions and 17 deletions
...@@ -237,45 +237,47 @@ describe(Support.getTestDialectTeaser('Include'), function() { ...@@ -237,45 +237,47 @@ describe(Support.getTestDialectTeaser('Include'), function() {
Task.belongsTo(Project); Task.belongsTo(Project);
Task.belongsToMany(Tag, {through: TaskTag}); Task.belongsToMany(Tag, {through: TaskTag});
// Sync them // Sync them
return this.sequelize.sync({ force: true }).then(function () { return this.sequelize.sync({ force: true }).then(function() {
// Create an enviroment // Create an enviroment
return Promise.join( return User.bulkCreate([
User.bulkCreate([ { name: 'user-name-1' },
{ name: 'user-name-1' }, { name: 'user-name-2' }
{ name: 'user-name-2' } ]).then(function(u){
]), return Project.bulkCreate([
Project.bulkCreate([
{ m: 'A', UserId: 1}, { m: 'A', UserId: 1},
{ m: 'A', UserId: 2}, { m: 'A', UserId: 2},
]), ]);
Task.bulkCreate([ }).then(function(p){
return Task.bulkCreate([
{ ProjectId: 1, name: 'Just' }, { ProjectId: 1, name: 'Just' },
{ ProjectId: 1, name: 'for' }, { ProjectId: 1, name: 'for' },
{ ProjectId: 2, name: 'testing' }, { ProjectId: 2, name: 'testing' },
{ ProjectId: 2, name: 'proposes' } { ProjectId: 2, name: 'proposes' }
]) ]);
).then(function() { })
.then(function() {
// Find All Tasks with Project(m=a) and User(name=user-name-2) // Find All Tasks with Project(m=a) and User(name=user-name-2)
return Task.findAndCountAll({ return Task.findAndCountAll({
limit: 2, limit: 1,
offset: 0, offset: 0,
order: [[ 'id', 'ASC' ]], order: [[ 'id', 'DESC' ]],
include: [ include: [
{ model: Project, {
model: Project,
where: { '$and': [ { m: 'A' } ] } , where: { '$and': [ { m: 'A' } ] } ,
include: [ { include: [ {
model: User, model: User,
where: { '$and': [ { name: 'user-name-2' } ] } where: { '$and': [ { name: 'user-name-2' } ] }
} }
] ]
}, {model : Tag} },
{ model : Tag }
] ]
}); });
}); });
}).then(function(result) { }).then(function(result) {
expect(result.count).to.equal(2); expect(result.count).to.equal(2);
expect(result.rows.length).to.equal(2); expect(result.rows.length).to.equal(1);
}); });
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!