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

Commit 00de8764 by Daniel Durante

Merge branch 'master' into milestones/2.0.0

2 parents fcbac2fb 65fe70fd
Showing with 64 additions and 0 deletions
......@@ -261,6 +261,7 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
}
describe('#create', function() {
describe('generic', function() {
beforeEach(function(done) {
var self = this
......@@ -305,6 +306,69 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
})
})
})
})
describe('explicitly validating id/primary/auto incremented columns', function() {
it('should emit an error when we try to enter in a string for the id key without validation arguments', function(done) {
var User = this.sequelize.define('UserId', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
validate: {
isInt: true
}
}
})
User.sync({ force: true }).success(function() {
User.create({id: 'helloworld'}).error(function(err) {
expect(err).to.deep.equal({id: ['Invalid integer: id']})
done()
})
})
})
it('should emit an error when we try to enter in a string for the id key with validation arguments', function(done) {
var User = this.sequelize.define('UserId', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
validate: {
isInt: { args: true, msg: 'ID must be an integer!' }
}
}
})
User.sync({ force: true }).success(function() {
User.create({id: 'helloworld'}).error(function(err) {
expect(err).to.deep.equal({id: ['ID must be an integer!']})
done()
})
})
})
it('should emit an error when we try to enter in a string for an auto increment key (not named id)', function(done) {
var User = this.sequelize.define('UserId', {
username: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
validate: {
isInt: { args: true, msg: 'Username must be an integer!' }
}
}
})
User.sync({ force: true }).success(function() {
User.create({username: 'helloworldhelloworld'}).error(function(err) {
expect(err).to.deep.equal({username: ['Username must be an integer!']})
done()
})
})
})
})
it('correctly throws an error using create method ', 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!