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

Commit 8a732fc1 by Mick Hansen

Merge pull request #5115 from sushantdhiman/fix-1150

Fix(#1150) : Test to verify findAll / find properly clone options
2 parents 619fde9d f5d6c287
......@@ -6,7 +6,8 @@ var chai = require('chai')
, Support = require(__dirname + '/../support')
, current = Support.sequelize
, sinon = require('sinon')
, DataTypes = require(__dirname + '/../../../lib/data-types');
, DataTypes = require(__dirname + '/../../../lib/data-types')
, _ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), function() {
describe('method findAll', function () {
......@@ -87,6 +88,20 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]);
});
});
it('properly clones options values', function() {
var options = {
attributes: {
exclude: ['name'],
include: ['name']
}
};
var optionsClones = _.cloneDeep(options);
return Model.findAll(options).bind(this).then(function () {
expect(options).to.deep.equal(optionsClones);
});
});
});
});
});
......@@ -7,7 +7,8 @@ var chai = require('chai')
, current = Support.sequelize
, sinon = require('sinon')
, DataTypes = require(__dirname + '/../../../lib/data-types')
, Promise = require('bluebird');
, Promise = require('bluebird')
, _ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), function() {
describe('method findOne', function () {
......@@ -67,5 +68,16 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(this.stub.getCall(0).args[0]).to.be.an('object').to.have.property('limit');
});
});
it('properly clones options values', function() {
var options = { where: { id: { $gt: 42 }}}
, optionsClones = _.cloneDeep(options)
, Model = current.define('model');
return Model.findOne(options).bind(this).then(function () {
expect(options).to.deep.equal(optionsClones);
});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!