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

Commit 6f4cdcfa by Sushant

(tests) #4091, queries returns to 1=1 when non POJO used

1 parent ef7793b8
'use strict';
/* jshint -W030 */
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, current = Support.sequelize
, sinon = require('sinon')
, Promise = current.Promise
, DataTypes = require('../../../lib/data-types')
, _ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), function() {
describe('method destroy', function () {
var User = current.define('User', {
name: DataTypes.STRING,
secretValue: DataTypes.INTEGER
});
before(function () {
this.stubUpdate = sinon.stub(current.getQueryInterface(), 'bulkDelete', function () {
return Promise.resolve([]);
});
});
beforeEach(function () {
this.options = {where: {secretValue: '1'}}
this.cloneOptions = _.clone(this.options);
this.stubUpdate.reset();
});
afterEach(function () {
delete this.options;
delete this.cloneOptions;
});
after(function () {
this.stubUpdate.restore();
});
it('properly clones options', function() {
var self = this;
return User.destroy(self.options).bind(this).then(function(e) {
expect(self.options).to.be.deep.eql(self.cloneOptions);
});
});
it('can detect complexe objects', function() {
var self = this;
var where = function () { this.secretValue = '1'; }
return expect(User.destroy({where:new where})).to.eventually.be.rejectedWith(Error);
});
});
});
......@@ -55,5 +55,10 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
it('can detect complexe objects', function() {
var self = this;
var where = function () { this.secretValue = '1'; }
return expect(User.update(self.updates, {where:new where})).to.eventually.be.rejectedWith(Error);
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!