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

Commit ff5db2f1 by Sascha Depold

one last test + fix for has_one

1 parent 27ba66e5
......@@ -88,7 +88,7 @@ module.exports = (function() {
oldObj[self.identifier] = null
oldObj
.save(
Utils._.extend(options, {
Utils._.extend({}, options, {
fields: [self.identifier],
allowNull: [self.identifier]
})
......
......@@ -217,12 +217,12 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
sequelize.transaction(function(t) {
article.setLabels([ label ], { transaction: t }).success(function() {
Label
.findAll({ where: { articleId: article.id }, transaction: undefined })
.findAll({ where: { ArticleId: article.id }, transaction: undefined })
.success(function(labels) {
expect(labels.length).to.equal(0)
Label
.findAll({ where: { articleId: article.id }, transaction: t })
.findAll({ where: { ArticleId: article.id }, transaction: t })
.success(function(labels) {
expect(labels.length).to.equal(1)
t.rollback().success(function() { done() })
......
......@@ -75,9 +75,36 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
})
describe('setAssociation', function() {
it('supports transactions', function(done) {
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: Support.Sequelize.STRING })
, Group = sequelize.define('Group', { name: Support.Sequelize.STRING })
Group.hasOne(User)
sequelize.sync({ force: true }).success(function() {
User.create({ username: 'foo' }).success(function(user) {
Group.create({ name: 'bar' }).success(function(group) {
sequelize.transaction(function(t) {
group.setUser(user, { transaction: t }).success(function() {
Group.all().success(function(groups) {
groups[0].getUser().success(function(associatedUser) {
expect(associatedUser).to.be.null
t.rollback().success(function() { done() })
})
})
})
})
})
})
})
})
})
it('can set an association with predefined primary keys', function(done) {
var User = this.sequelize.define('UserXYZZ', { userCoolIdTag: { type: Sequelize.INTEGER, primaryKey: true }, username: Sequelize.STRING })
, Task = this.sequelize.define('TaskXYZZ', { taskOrSomething: { type: Sequelize.INTEGER, primaryKey: true }, title: Sequelize.STRING })
, self = this
User.hasOne(Task, {foreignKey: 'userCoolIdTag'})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!