diff --git a/test/migration.coffee b/test/migration.coffee index 14a9745..f9da62a 100644 --- a/test/migration.coffee +++ b/test/migration.coffee @@ -2,12 +2,12 @@ juggling = require('jugglingdb') Schema = juggling.Schema Text = Schema.Text -DBNAME = process.env.DBNAME || 'myapp_test' -DBUSER = process.env.DBUSER || 'root' +DBNAME = 'myapp_test' +DBUSER = 'root' DBPASS = '' -DBENGINE = process.env.DBENGINE || 'mysql' +DBENGINE = 'mysql' -schema = new Schema DBENGINE, database: '', username: DBUSER, password: DBPASS +schema = new Schema __dirname + '/..', database: '', username: DBUSER, password: DBPASS schema.log = (q) -> console.log q query = (sql, cb) -> diff --git a/test/mysql.js b/test/mysql.js index 4c50b53..654eabe 100644 --- a/test/mysql.js +++ b/test/mysql.js @@ -8,3 +8,21 @@ var jdb = require('jugglingdb'), test(module.exports, schema); +var Post, User; + +test.it('hasMany should support additional conditions', function (test) { + + Post = schema.models.Post; + User = schema.models.User; + + User.create(function (e, u) { + u.posts.create({}, function (e, p) { + u.posts({where: {id: p.id}}, function (e, posts) { + test.equal(posts.length, 1, 'There should be only 1 post.'); + test.done(); + }); + }); + }); + +}); +