Skip to content

Commit

Permalink
Merge pull request sequelize#1623 from cusspvz/master
Browse files Browse the repository at this point in the history
Cleaning unneeded stuff
  • Loading branch information
mickhansen committed Apr 10, 2014
2 parents 739ed5c + 17e3daf commit bf087b1
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 120 deletions.
6 changes: 3 additions & 3 deletions test/associations/belongs-to.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
User.sync({ force: true }).success(function() {
Task.sync({ force: true }).success(function() {
User.create({ username: 'foo', gender: 'male' }).success(function(user) {
User.create({ username: 'bar', gender: 'female' }).success(function(falsePositiveCheck) {
User.create({ username: 'bar', gender: 'female' }).success(function() {
Task.create({ title: 'task', status: 'inactive' }).success(function(task) {
task.setUserXYZ(user).success(function() {
task.getUserXYZ({where: ['gender = ?', 'female']}).success(function(user) {
Expand Down Expand Up @@ -195,14 +195,14 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
Post.hasOne(Comment);
Comment.belongsTo(Post);

this.sequelize.sync().done(function (err) {
this.sequelize.sync().done(function () {
Post.create({
title: 'Post title',
}).done(function(err, post) {
Comment.create({
text: 'OLD VALUE',
}).done(function(err, comment) {
comment.setPost(post).done(function(err) {
comment.setPost(post).done(function() {
expect(comment.text).to.equal('UPDATED VALUE');
done()
});
Expand Down
17 changes: 5 additions & 12 deletions test/associations/has-many.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {

describe('hasAll', function() {
beforeEach(function(done) {
var self = this
this.Article = this.sequelize.define('Article', {
'title': DataTypes.STRING
})
Expand Down Expand Up @@ -332,7 +331,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
Article.sync({ force: true }).success(function() {
Label.sync({ force: true }).success(function() {
Article.create({ title: 'foo' }).success(function(article) {
article.createLabel({ text: 'bar' }).success(function(label) {
article.createLabel({ text: 'bar' }).success(function() {

Label
.findAll({ where: { ArticleId: article.id }})
Expand Down Expand Up @@ -377,7 +376,6 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})

it('supports transactions', function(done) {
var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var Article = sequelize.define('Article', { 'title': DataTypes.STRING })
, Label = sequelize.define('Label', { 'text': DataTypes.STRING })
Expand Down Expand Up @@ -868,7 +866,6 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})

it('supports transactions', function(done) {
var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('User', { username: DataTypes.STRING })
, Task = sequelize.define('Task', { title: DataTypes.STRING })
Expand Down Expand Up @@ -928,7 +925,6 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {

describe('optimizations using bulk create, destroy and update', function () {
beforeEach(function (done) {
var self = this
this.User = this.sequelize.define('User', { username: DataTypes.STRING }, {timestamps: false})
this.Task = this.sequelize.define('Task', { title: DataTypes.STRING }, {timestamps: false})

Expand Down Expand Up @@ -1042,7 +1038,6 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {

describe('primary key handling for join table', function () {
beforeEach(function (done) {
var self = this
this.User = this.sequelize.define('User',
{ username: DataTypes.STRING },
{ tableName: 'users'}
Expand Down Expand Up @@ -1313,7 +1308,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
expect(err).not.to.be.ok
Task.findAll().done(function (err, tasks) {
expect(err).not.to.be.ok
worker.setTasks(tasks).done(function (err) {
worker.setTasks(tasks).done(function () {
worker.setTasks(tasks).done(function (err) {
expect(err).not.to.be.ok
done()
Expand Down Expand Up @@ -1344,7 +1339,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
expect(err).not.to.be.ok
Task.findAll().done(function (err, tasks) {
expect(err).not.to.be.ok
worker.setTasks(tasks).done(function (err) {
worker.setTasks(tasks).done(function () {
worker.removeTask(tasks[0]).done(function (err) {
expect(err).not.to.be.ok

Expand Down Expand Up @@ -1462,8 +1457,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})

it("correctly identifies its counterpart when through is a string", function (done) {
var self = this
, User = this.sequelize.define('User', {})
var User = this.sequelize.define('User', {})
, Group = this.sequelize.define('Group', {})

User.hasMany(Group, { as: 'MyGroups', through: 'group_user'})
Expand All @@ -1479,8 +1473,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})

it("correctly identifies its counterpart when through is a model", function (done) {
var self = this
, User = this.sequelize.define('User', {})
var User = this.sequelize.define('User', {})
, Group = this.sequelize.define('Group', {})
, UserGroup = this.sequelize.define('GroupUser', {}, {tableName: 'user_groups'})

Expand Down
3 changes: 1 addition & 2 deletions test/associations/has-one.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
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'})

Expand Down Expand Up @@ -191,7 +190,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
sequelize.sync({ force: true }).success(function() {
User.create({ username: 'bob' }).success(function(user) {
sequelize.transaction(function(t) {
user.createGroup({ name: 'testgroup' }, { transaction: t }).success(function(group) {
user.createGroup({ name: 'testgroup' }, { transaction: t }).success(function() {
User.all().success(function (users) {
users[0].getGroup().success(function (group) {
expect(group).to.be.null;
Expand Down
5 changes: 0 additions & 5 deletions test/dao-factory/and-or-where.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ var chai = require('chai')
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')

chai.use(datetime)
chai.config.includeStack = true
Expand Down
26 changes: 10 additions & 16 deletions test/dao-factory/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ var chai = require('chai')
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')

chai.use(datetime)
chai.config.includeStack = true
Expand All @@ -35,7 +31,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

describe('findOrCreate', function () {
it("supports transactions", function(done) {
var self = this

Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('user_with_transaction', { username: Sequelize.STRING, data: Sequelize.STRING })
Expand Down Expand Up @@ -180,7 +175,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})

it('supports transactions', function(done) {
var self = this

Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('user_with_transaction', { username: Sequelize.STRING })
Expand Down Expand Up @@ -697,7 +691,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

it('should allow blank creates (with timestamps: false)', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.create({}, {fields: []}).done(function (err, worker) {
expect(err).not.to.be.ok
expect(worker).to.be.ok
Expand All @@ -708,7 +702,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

it('should allow truly blank creates', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.create({}, {fields: []}).done(function (err, worker) {
expect(err).not.to.be.ok
expect(worker).to.be.ok
Expand Down Expand Up @@ -791,7 +785,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})

Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
Expand All @@ -803,7 +797,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})

Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
Expand All @@ -819,7 +813,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})

Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
Expand All @@ -833,14 +827,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})

Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
})
})

describe('can safely sync multiple times', function(done) {
describe('can safely sync multiple times', function() {
it('through the factory', function(done) {
var Enum = this.sequelize.define('Enum', {
state: {
Expand Down Expand Up @@ -1095,7 +1089,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

it('should allow blank arrays (return immediatly)', function (done) {
var Worker = this.sequelize.define('Worker', {})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.bulkCreate([]).done(function (err, workers) {
expect(err).not.to.be.ok
expect(workers).to.be.ok
Expand All @@ -1107,7 +1101,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

it('should allow blank creates (with timestamps: false)', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.bulkCreate([{}, {}]).done(function (err, workers) {
expect(err).not.to.be.ok
expect(workers).to.be.ok
Expand All @@ -1118,7 +1112,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

it('should allow autoincremented attributes to be set', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.bulkCreate([
{id: 5},
{id: 10}
Expand Down
23 changes: 10 additions & 13 deletions test/dao-factory/find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')

chai.use(datetime)
Expand Down Expand Up @@ -79,7 +76,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('does not modify the passed arguments', function (done) {
var options = { where: ['specialkey = ?', 'awesome']}

this.UserPrimary.find(options).success(function(user) {
this.UserPrimary.find(options).success(function() {
expect(options).to.deep.equal({ where: ['specialkey = ?', 'awesome']})
done()
})
Expand All @@ -101,7 +98,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})

xit('doesn\'t throw an error when entering in a non integer value', function(done) {
it.skip('doesn\'t throw an error when entering in a non integer value', function(done) {
this.User.find('a string value').success(function(user) {
expect(user).to.be.null
done()
Expand Down Expand Up @@ -218,7 +215,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
UserPrimary.create({
id: 'a string based id',
name: 'Johnno'
}).success(function(u) {
}).success(function() {
UserPrimary.find('a string based id').success(function(u2) {
expect(u2.id).to.equal('a string based id')
expect(u2.name).to.equal('Johnno')
Expand Down Expand Up @@ -420,8 +417,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

this.sequelize.sync({ force: true }).success(function() {
User.create({username: 'test_testerson'}).success(function(user) {
Message.create({user_id: user.id, message: 'hi there!'}).success(function(message) {
Message.create({user_id: user.id, message: 'a second message'}).success(function(message) {
Message.create({user_id: user.id, message: 'hi there!'}).success(function() {
Message.create({user_id: user.id, message: 'a second message'}).success(function() {
Message.findAll({

where: {user_id: user.id},
Expand Down Expand Up @@ -546,7 +543,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
done()
})

describe('alias', function(done) {
describe('alias', function() {
beforeEach(function(done) {
var self = this
this.Worker.hasOne(this.Task, { as: 'ToDo' })
Expand Down Expand Up @@ -654,9 +651,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
self.Photo.create({ img: 'img.jpg' }).success(function(somePhoto) {
self.PhoneNumber.create({ phone: '000000' }).success(function(somePhone1) {
self.PhoneNumber.create({ phone: '111111' }).success(function(somePhone2) {
someContact.setPhotos([somePhoto]).complete(function (err, data) {
someContact.setPhotos([somePhoto]).complete(function (err) {
expect(err).to.be.null
someContact.setPhoneNumbers([somePhone1, somePhone2]).complete(function (err, data) {
someContact.setPhoneNumbers([somePhone1, somePhone2]).complete(function () {
self.Contact.find({
where: {
name: 'Boris'
Expand Down Expand Up @@ -698,7 +695,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
self.sequelize.sync({ force: true }).success(function() {
self.User.create({ username: 'someone' }).success(function(someUser) {
self.Group.create({ name: 'people' }).success(function(someGroup) {
someUser.setGroupPKeagerones([someGroup]).complete(function (err, data) {
someUser.setGroupPKeagerones([someGroup]).complete(function (err) {
expect(err).to.be.null
self.User.find({
where: {
Expand Down Expand Up @@ -803,7 +800,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.Product.hasMany(this.Tag, {as: 'Tags', through: 'product_tag'})
this.Tag.hasMany(this.Product, {as: 'Products', through: 'product_tag'})

this.sequelize.sync().done(function (err) {
this.sequelize.sync().done(function () {
async.auto({
createProducts: function (callback) {
self.Product.bulkCreate([
Expand Down
8 changes: 3 additions & 5 deletions test/dao-factory/findAll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var chai = require('chai')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
Expand Down Expand Up @@ -62,15 +61,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {

describe('special where conditions/smartWhere object', function() {
beforeEach(function(done) {
var self = this

this.buf = new Buffer(16);
this.buf.fill('\x01');

this.User.bulkCreate([
{username: 'boo', intVal: 5, theDate: '2013-01-01 12:00'},
{username: 'boo2', intVal: 10, theDate: '2013-01-10 12:00', binary: this.buf }
]).success(function(user2) {
]).success(function() {
done()
})
})
Expand All @@ -91,7 +89,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
where: {
id: [1, 2, 3]
}
}).success(function(users){
}).success(function(){
done();
});
})
Expand Down Expand Up @@ -1225,7 +1223,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('does not modify the passed arguments', function (done) {
var options = { where: ['username = ?', 'awesome']}

this.User.findAll(options).success(function(user) {
this.User.findAll(options).success(function() {
expect(options).to.deep.equal({ where: ['username = ?', 'awesome']})
done()
})
Expand Down
Loading

0 comments on commit bf087b1

Please sign in to comment.