Skip to content

Commit

Permalink
tests; clean up rebase mess
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Aug 19, 2013
1 parent f6d2f9e commit 663d911
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
39 changes: 0 additions & 39 deletions lib/drivers/node-mongodb-native/connection.js
Expand Up @@ -113,51 +113,12 @@ NativeConnection.prototype.useDb = function (name) {
listen(newConn);
}

// we have to manually copy all of the attributes...
var newConn = new this.constructor();
newConn.base = this.base;
newConn.collections = {};
newConn.models = {};
newConn.replica = this.replica;
newConn.hosts = this.hosts;
newConn.host = this.host;
newConn.port = this.port;
newConn.user = this.user;
newConn.pass = this.pass;
newConn.options = this.options;
newConn._readyState = this._readyState;
newConn._closeCalled = this._closeCalled;
newConn._hasOpened = this._hasOpened;
newConn._listening = false;

// Explanation for this whole mess:
// First, when we create another db object, we are not guaranteed to have a
// db object to work with. So, in the case where we have a db object and it
// is connected, we can just proceed with setting everything up. However, if
// we do not have a db or the state is not connected, then we need to wait on
// the 'open' event of the connection before doing the rest of the setup
// the 'connected' event is the first time we'll have access to the db object
if (this.db && this.db._state == 'connected') {
newConn.db = this.db.db(name);
newConn.onOpen();
// setup the events appropriately
listen(newConn);
} else {
var self = this;
this.once('connected', function () {
newConn.db = self.db.db(name);
newConn.onOpen();
// setup the events appropriately
listen(newConn);
});
}
newConn.name = name;

// push onto the otherDbs stack, this is used when state changes
this.otherDbs.push(newConn);
newConn.otherDbs.push(this);


return newConn;
};

Expand Down
2 changes: 1 addition & 1 deletion test/connection.test.js
Expand Up @@ -893,7 +893,7 @@ describe('connections:', function(){
})
})

describe.only('connection pool sharing: ', function () {
describe('connection pool sharing: ', function () {
it('works', function (done) {
var db = mongoose.createConnection('mongodb://localhost/mongoose1');

Expand Down

0 comments on commit 663d911

Please sign in to comment.