From 86a85291ac54ed11d181945040fe9f4d3fdc1fae Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Thu, 23 Jan 2014 14:39:15 -0800 Subject: [PATCH] Fix user test race condition --- test/user.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/user.test.js b/test/user.test.js index fecc52d8..20271335 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -1,4 +1,4 @@ -var User = loopback.User.extend('user'); +var User; var AccessToken = loopback.AccessToken; var passport = require('passport'); var MailConnector = require('../lib/connectors/mail'); @@ -8,10 +8,14 @@ var userMemory = loopback.createDataSource({ }); describe('User', function(){ - // allow many User.afterRemote's to be called - User.setMaxListeners(0); + beforeEach(function() { + User = loopback.User.extend('user'); + User.email = loopback.Email.extend('email'); + loopback.autoAttach(); - before(function () { + // allow many User.afterRemote's to be called + User.setMaxListeners(0); + User.hasMany(AccessToken, {as: 'accessTokens', foreignKey: 'userId'}); AccessToken.belongsTo(User); });