Skip to content

Commit

Permalink
Merge a72a60d into 50f6ac1
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jan 3, 2017
2 parents 50f6ac1 + a72a60d commit 47d2a48
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/node_modules/pouchdb-mapreduce/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions tests/mapreduce/test.persisted.js
Expand Up @@ -460,6 +460,58 @@ function tests(suiteName, dbName, dbType) {
});
}

it('test docs with reserved IDs', function () {
var db = new PouchDB(dbName);

var docs = [
{_id: 'constructor'},
{_id: 'isPrototypeOf'},
{_id: 'hasOwnProperty'},
{
_id : '_design/view',
views : {
view : {
map : "function(doc){emit(doc._id);}"
}
}
}
];
return db.bulkDocs(docs).then(function () {
return db.query('view/view', {include_docs: true});
}).then(function (res) {
var rows = res.rows.map(function (row) {
return {
id: row.id,
key: row.key,
docId: row.doc._id
};
});
assert.deepEqual(rows, [
{ "id": "constructor",
"key": "constructor",
"docId": "constructor"
},
{
"id": "hasOwnProperty",
"key": "hasOwnProperty",
"docId": "hasOwnProperty"
},
{
"id": "isPrototypeOf",
"key": "isPrototypeOf",
"docId": "isPrototypeOf"
}
]);
return db.viewCleanup();
}).then(function () {
return db.get('_design/view');
}).then(function (doc) {
return db.remove(doc);
}).then(function () {
return db.viewCleanup();
});
});

it('should handle user errors in design doc names', function () {
var db = new PouchDB(dbName);
return db.put({
Expand Down

0 comments on commit 47d2a48

Please sign in to comment.