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

Commit 52dbeb3b by Jan Aagaard Meier

test(btm/timestamps) Tests for #3792

1 parent be653528
...@@ -292,7 +292,6 @@ Mixin.belongsToMany = function(targetModel, options) { // testhint options:none ...@@ -292,7 +292,6 @@ Mixin.belongsToMany = function(targetModel, options) { // testhint options:none
options.hooks = options.hooks === undefined ? false : Boolean(options.hooks); options.hooks = options.hooks === undefined ? false : Boolean(options.hooks);
options.useHooks = options.hooks; options.useHooks = options.hooks;
options.timestamps = options.timestamps === undefined ? this.sequelize.options.timestamps : options.timestamps; options.timestamps = options.timestamps === undefined ? this.sequelize.options.timestamps : options.timestamps;
options = _.extend(options, _.omit(sourceModel.options, ['hooks', 'timestamps'])); options = _.extend(options, _.omit(sourceModel.options, ['hooks', 'timestamps']));
// the id is in the foreign table or in a connecting table // the id is in the foreign table or in a connecting table
......
...@@ -14,6 +14,39 @@ var chai = require('chai') ...@@ -14,6 +14,39 @@ var chai = require('chai')
, Promise = current.Promise; , Promise = current.Promise;
describe(Support.getTestDialectTeaser('belongsToMany'), function() { describe(Support.getTestDialectTeaser('belongsToMany'), function() {
describe('timestamps', function () {
it('follows the global timestamps true option', function () {
var User = current.define('User', {})
, Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task1' });
expect(current.models.user_task1.rawAttributes).to.contain.all.keys(['createdAt', 'updatedAt']);
});
it('allows me to override the global timestamps option', function () {
var User = current.define('User', {})
, Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task2', timestamps: false });
expect(current.models.user_task2.rawAttributes).not.to.contain.all.keys(['createdAt', 'updatedAt']);
});
it('follows the global timestamps false option', function () {
var current = Support.createSequelizeInstance({
timestamps: false
});
var User = current.define('User', {})
, Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task3' });
expect(current.models.user_task3.rawAttributes).not.to.have.all.keys(['createdAt', 'updatedAt']);
});
});
describe('optimizations using bulk create, destroy and update', function() { describe('optimizations using bulk create, destroy and update', function() {
var User = current.define('User', { username: DataTypes.STRING }) var User = current.define('User', { username: DataTypes.STRING })
, Task = current.define('Task', { title: DataTypes.STRING }) , Task = current.define('Task', { title: DataTypes.STRING })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!