diff options
author | Robert Newson <rnewson@apache.org> | 2010-09-30 12:22:29 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2010-09-30 12:22:29 +0000 |
commit | 5d918e616119e308ca38dc847dd8165e089557dc (patch) | |
tree | 5fc0ae5671dec07003c98f4ec812b879206ffc9b /share/www/script | |
parent | 6ae13b5f8b827bc87a8cf3306c3caa1b97e49df3 (diff) |
COUCHDB-903 - add {ok, true} to COPY result.
Thanks to Bob Dionne for original patch. I've modified it to fix the badmatch error if you do COPY without a Destination header. It now yields a 400 (Bad Request) error without spewing a stack trace.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1003035 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/couch.js | 2 | ||||
-rw-r--r-- | share/www/script/test/copy_doc.js | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 913f58fb..633abe96 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -121,7 +121,7 @@ function CouchDB(name, httpHeaders) { CouchDB.maybeThrowError(this.last_req); var results = JSON.parse(this.last_req.responseText); for (var i = 0; i < docs.length; i++) { - if(results[i] && results[i].rev) { + if(results[i] && results[i].rev && results[i].ok) { docs[i]._rev = results[i].rev; } } diff --git a/share/www/script/test/copy_doc.js b/share/www/script/test/copy_doc.js index a6de1892..a15e3ef8 100644 --- a/share/www/script/test/copy_doc.js +++ b/share/www/script/test/copy_doc.js @@ -23,6 +23,7 @@ couchTests.copy_doc = function(debug) { }); T(xhr.status == 201); + T(JSON.parse(xhr.responseText).ok); T(db.open("doc_that_was_copied").v == 1); // COPY with existing target @@ -36,6 +37,10 @@ couchTests.copy_doc = function(debug) { }); T(xhr.status == 409); // conflict + // missing Destination header + var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2"); + T(xhr.status == 400); // bad request + var rev = db.open("doc_to_be_overwritten")._rev; var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied2", { headers: {"Destination":"doc_to_be_overwritten?rev=" + rev} |