Commit fa9abed5 authored by Sven Franck's avatar Sven Franck

replicate revision, remove method, bugfixes

parent 5f757590
...@@ -660,9 +660,9 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -660,9 +660,9 @@ jIO.addStorageType('revision', function (spec, my) {
f.removeDocument = function (docid, doctree) { f.removeDocument = function (docid, doctree) {
if (command.getOption("keep_revision_history") !== true) { if (command.getOption("keep_revision_history") !== true) {
if (command.getAttachmentId() === undefined){ if (command.getAttachmentId() === undefined){
// update tree // update tree
priv.postToDocumentTree(doctree, command.getDoc(), true); revs_info = priv.postToDocumentTree(doctree,
command.getDoc(), true);
// remove revision // remove revision
that.addJob( that.addJob(
...@@ -671,17 +671,19 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -671,17 +671,19 @@ jIO.addStorageType('revision', function (spec, my) {
docid, docid,
option, option,
function (response) { function (response) {
// put tree // put tree
doctree._id = command.getDocId()+
priv.doctree_suffix;
that.addJob( that.addJob(
"put", "put",
priv.substorage, priv.substorage,
doctree, doctree,
command.cloneOption(), command.cloneOption(),
function (response) { function (response) {
that.success({ that.success({
"ok":true, "ok":true,
"id":docid, "id":command.getDocId(),
"rev":revs_info[0].rev "rev":revs_info[0].rev
}); });
}, },
......
...@@ -1503,7 +1503,7 @@ test ("Remove", function(){ ...@@ -1503,7 +1503,7 @@ test ("Remove", function(){
// 10. remove wrong revision // 10. remove wrong revision
o.spy (o,"status", 409, "409 - Removing document (false revision)"); o.spy (o,"status", 409, "409 - Removing document (false revision)");
o.jio.remove({"_id":"remove1","_rev":o.second_old_rev}, o.f); o.jio.remove({"_id":"remove1","_rev":"1-rev2"}, o.f);
o.tick(o); o.tick(o);
o.revisions = {"start": 3, "ids":[ o.revisions = {"start": 3, "ids":[
...@@ -1515,7 +1515,8 @@ test ("Remove", function(){ ...@@ -1515,7 +1515,8 @@ test ("Remove", function(){
generateRevisionHash(o.doc_myremove4, o.revisions, true); generateRevisionHash(o.doc_myremove4, o.revisions, true);
// 11. remove document version with revision // 11. remove document version with revision
o.spy (o, "value", {"ok": true, "id": "remove1", "rev": o.second_new_rev}, o.spy (o, "value", {"ok": true, "id": "remove1", "rev":
o.second_new_rev},
"Remove document (with revision)"); "Remove document (with revision)");
o.jio.remove({"_id":"remove1", "_rev":o.rev}, o.f); o.jio.remove({"_id":"remove1", "_rev":o.rev}, o.f);
o.tick(o); o.tick(o);
...@@ -1525,7 +1526,12 @@ test ("Remove", function(){ ...@@ -1525,7 +1526,12 @@ test ("Remove", function(){
"status": "deleted", "status": "deleted",
"children": [] "children": []
}); });
/* o.testtree["children"][1]["children"].push({
"rev":o.second_old_rev,
"status":"available",
"children":[]
});
deepEqual(localstorage.getItem( deepEqual(localstorage.getItem(
"jio/localstorage/urevrem/arevrem/remove1.revision_tree.json" "jio/localstorage/urevrem/arevrem/remove1.revision_tree.json"
), o.testtree, "Check document tree"); ), o.testtree, "Check document tree");
...@@ -1542,7 +1548,7 @@ test ("Remove", function(){ ...@@ -1542,7 +1548,7 @@ test ("Remove", function(){
o.spy (o,"status", 409, "409 - Removing document (no revision)"); o.spy (o,"status", 409, "409 - Removing document (no revision)");
o.jio.remove({"_id":"remove1"}, o.f); o.jio.remove({"_id":"remove1"}, o.f);
o.tick(o); o.tick(o);
*/
o.jio.stop(); o.jio.stop();
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment