Permalink
Browse files

Fix findAndLoad

  • Loading branch information...
1 parent 91bbbac commit 8bb8513fdb376601964dc0329c6bd6d667fd7037 @maritz committed Dec 4, 2012
Showing with 18 additions and 5 deletions.
  1. +3 −2 lib/retrieve.js
  2. +15 −3 test/findTests.js
View
@@ -83,8 +83,9 @@ exports.findAndLoad = function findAndLoad(searches, callback) {
} else {
if (ids.length > 0) {
async.map(ids, function (id, done) {
- self.load(id, function (err) {
- done(err, self);
+ var instance = Nohm.factory(self.modelName);
+ instance.load(id, function (err) {
+ done(err, instance);
});
}, callback);
}
View
@@ -208,13 +208,25 @@ exports.find = {
findAndLoad: function (t) {
var user = new UserFindMockup();
+ var user2 = new UserFindMockup();
user.p({
name: 'hurgelwurz',
email: 'hurgelwurz@hurgel.de',
});
+ user2.p({
+ name: 'hurgelwurz',
+ email: 'hurgelwurz2@hurgel.de',
+ });
- user.save(function(err) {
+ async.parallel([
+ function (done) {
+ user.save(done);
+ },
+ function (done) {
+ user2.save(done);
+ }
+ ], function(err) {
if (err) {
console.dir(err);
t.done();
@@ -224,8 +236,8 @@ exports.find = {
console.dir(err);
t.done();
}
-
- t.equals(users.length, 1, 'The loaded number of users equals 1');
+ console.log(users[1].p('email'));
+ t.equals(users.length, 2, 'The loaded number of users was not 2.');
t.equals(user.p('name'), users[0].p('name'), 'The loaded version of the name was not the same as a set one.');
t.equals(user.p('email'), users[0].p('email'), 'The loaded version of the email was not the same as a set one.');
t.equals(user.id, users[0].id, 'The loaded version of the email was not the same as a set one.');

0 comments on commit 8bb8513

Please sign in to comment.