From e78fab6f5bfe0278c28e5121cd4e33f23cd80ac4 Mon Sep 17 00:00:00 2001
From: Anatoliy Chakkaev <anatoliy.chakkaev@flatsoft.com>
Date: Sat, 15 Dec 2012 00:09:42 +0400
Subject: [PATCH] Additonal test case

---
 test/migration.coffee |  8 ++++----
 test/mysql.js         | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

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();
+            });
+        });
+    });
+
+});
+