summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes J. Schmidt <schmidt@netzmerk.com>2013-03-28 00:11:26 +0100
committerJohannes J. Schmidt <schmidt@netzmerk.com>2013-03-28 00:11:26 +0100
commit83593ac45d056e07223aaca82d3b16cb46ab8e2e (patch)
treedacef5c2477779ae7bd6f90dd7adeae553c34d4e
parentfe2dca093a629097b9d0e1e0575e9044a5908df3 (diff)
downloadcouchdb-83593ac45d056e07223aaca82d3b16cb46ab8e2e.tar.gz
Test form-urlencoded doc update
Update handlers have access to a form object parsed from an application/x-www-form-urlencoded request.
-rw-r--r--share/www/script/test/update_documents.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js
index 32ec72e74..868421770 100644
--- a/share/www/script/test/update_documents.js
+++ b/share/www/script/test/update_documents.js
@@ -50,6 +50,13 @@ couchTests.update_documents = function(debug) {
doc[field] = value;
return [doc, message];
}),
+ "form-update" : stringFun(function(doc, req) {
+ for (var field in req.form) {
+ doc[field] = req.form[field];
+ }
+ var message = "updated doc from form";
+ return [doc, message];
+ }),
"bump-counter" : stringFun(function(doc, req) {
if (!doc.counter) doc.counter = 0;
doc.counter += 1;
@@ -156,6 +163,17 @@ couchTests.update_documents = function(debug) {
doc = db.open(docid);
T(doc.title == "test");
+ // form update via application/x-www-form-urlencoded
+ xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/form-update/"+docid, {
+ headers : {"Content-Type":"application/x-www-form-urlencoded"},
+ body : "formfoo=bar&formbar=foo"
+ });
+ TEquals(201, xhr.status);
+ TEquals("updated doc from form", xhr.responseText);
+ doc = db.open(docid);
+ TEquals("bar", doc.formfoo);
+ TEquals("foo", doc.formbar);
+
// bump counter
xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/bump-counter/"+docid, {
headers : {"X-Couch-Full-Commit":"true"}