require('../test_helper');

mongoose.connect('mongodb://127.0.0.1:27017/api_umbrella_test');

require('../factories/api_users');

var redis = require('redis'),
    DatabaseCleaner = require('database-cleaner');

before(function(done) {
  var databaseCleaner = new DatabaseCleaner('mongodb');
  databaseCleaner.clean(mongoose.connection.db, function() {
    done();
  });
});

before(function(done) {
  var client = redis.createClient();

  var databaseCleaner = new DatabaseCleaner('redis');
  databaseCleaner.clean(client, function() {
    done();
  });
});

require('../test_helper');

mongoose.connect('mongodb://127.0.0.1:27017/api_umbrella_test');

require('../factories/api_users');

var redis = require('redis'),
    DatabaseCleaner = require('database-cleaner');

before(function(done) {
  mongoose.connection.on('connected', function() {
    var databaseCleaner = new DatabaseCleaner('mongodb');
    databaseCleaner.clean(mongoose.connection.db, function() {
      done();
    });
  });
});

before(function(done) {
  var client = redis.createClient();

  var databaseCleaner = new DatabaseCleaner('redis');
  databaseCleaner.clean(client, function() {
    done();
  });
});

Fix race condition. Ensure mongo is connected before cleaning the db.
Fix race condition. Ensure mongo is connected before cleaning the db.
