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

Commit ece8f52d by Sohum Banerjea

test for the createAssoc single sql problem

1 parent 85a4166d
Showing with 26 additions and 0 deletions
...@@ -346,6 +346,32 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -346,6 +346,32 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}) })
}) })
it('creates the object with the association directly', function(done) {
var spy = sinon.spy()
var Article = this.sequelize.define('Article', { 'title': DataTypes.STRING })
, Label = this.sequelize.define('Label', { 'text': DataTypes.STRING,
'ArticleId': {
type: DataTypes.INTEGER,
allowNull: false
}})
Article.hasMany(Label)
Article.sync({ force: true }).success(function() {
Label.sync({ force: true }).success(function() {
Article.create({ title: 'foo' }).success(function(article) {
article.createLabel({ text: 'bar' }).on('sql', spy).complete(function(err, label) {
expect(err).to.not.be.ok
expect(spy.calledOnce).to.be.true
expect(label.ArticleId).to.equal(article.id)
done()
})
})
})
})
})
it('supports transactions', function(done) { it('supports transactions', function(done) {
var self = this var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) { Support.prepareTransactionTest(this.sequelize, function(sequelize) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!