From e77949221f63a011787118637cb549abfbd8e5e8 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Sat, 1 Oct 2011 03:20:05 +0000 Subject: fix COUCHDB-648 - _update handler ignores "code" Test by Christian Carter This is a backport of r1177890 git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1177892 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/update_documents.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'share/www/script') diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js index 4d2b29fc..59af4597 100644 --- a/share/www/script/test/update_documents.js +++ b/share/www/script/test/update_documents.js @@ -75,6 +75,17 @@ couchTests.update_documents = function(debug) { }), "get-uuid" : stringFun(function(doc, req) { return [null, req.uuid]; + }), + "code-n-bump" : stringFun(function(doc,req) { + if (!doc.counter) doc.counter = 0; + doc.counter += 1; + var message = "

bumped it!

"; + resp = {"code": 302, "body": message} + return [doc, resp]; + }), + "resp-code" : stringFun(function(doc,req) { + resp = {"code": 302} + return [null, resp]; }) } }; @@ -179,4 +190,17 @@ couchTests.update_documents = function(debug) { var doc = db.open("with/slash"); TEquals(2, doc.counter, "counter should be 2"); + + // COUCHDB-648 - the code in the JSON response should be honored + + xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/code-n-bump/"+docid, { + headers : {"X-Couch-Full-Commit":"true"} + }); + T(xhr.status == 302); + T(xhr.responseText == "

bumped it!

"); + doc = db.open(docid); + T(doc.counter == 3); + + xhr = CouchDB.request("POST", "/test_suite_db/_design/update/_update/resp-code/"); + T(xhr.status == 302); }; -- cgit v1.2.3