Skip to content

Commit 007f7cf

Browse files
committed
views tests
1 parent 870b7f3 commit 007f7cf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

plugins/views/tests.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -593,12 +593,13 @@ describe('Testing views plugin', function() {
593593
});
594594

595595
var check_if_merges_finished = function(tries, done) {
596-
if (tries == 5) {
596+
if (tries == 3) {
597597
done();
598598
}
599599
else {
600-
testUtils.db.collection("app_user_merges").findOne({"_id": {"$regex": "^" + APP_ID}}, function(err, res) {
601-
if (res) {
600+
testUtils.db.collection("app_user_merges").find({"_id": {"$regex": "^" + APP_ID}}).toArray(function(err, res) {
601+
if (res && res.length > 0) {
602+
console.log(JSON.stringify(res));
602603
setTimeout(function() {
603604
check_if_merges_finished(tries + 1, done);
604605
}, 10000);
@@ -735,15 +736,15 @@ describe('Testing views plugin', function() {
735736
setTimeout(function() {
736737
testUtils.db.collection("app_userviews" + APP_ID).aggregate([
737738
{ $replaceRoot: { newRoot: { _id: "$_id", "data": "$$ROOT"}}},
738-
{"$unionWith": {"coll": "app_userviews" + APP_ID, "pipeline": [{"$project": {"_id": "$uid", "userinfo": "$$ROOT"}}]}},
739+
{"$unionWith": {"coll": "app_users" + APP_ID, "pipeline": [{"$project": {"_id": "$uid", "userinfo": "$$ROOT"}}]}},
739740
{"$group": {"_id": "$_id", "userinfo": {"$addToSet": "$userinfo"}, "data": {"$addToSet": "$data"}}},
740-
{"$project": {"_id": 1, "userinfo": {"$first": "$userinfo"}, "data": {"$first": "$data"}}}
741+
{"$project": {"_id": 1, "userinfo": "$userinfo", "data": {"$first": "$data"}}}
741742
], function(err, res) {
742743
var userObject2 = {};
743744
console.log(JSON.stringify(res));
744745
for (var k = 0; k < res.length; k++) {
745746
if (res[k].userinfo && res[k].userinfo[0]) {
746-
userObject2[res[k].userinfo[0].did] = res[k];
747+
userObject2[res[k].userinfo[0].did] = res[k].data;
747748
delete res[k].userinfo;
748749
}
749750
}

0 commit comments

Comments
 (0)