couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [18/50] git commit: updated refs/heads/route-events to c33e390
Date Thu, 09 May 2013 14:01:15 GMT
Test form-urlencoded doc update

Update handlers have access to a form object parsed from an
application/x-www-form-urlencoded request.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/018d114c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/018d114c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/018d114c

Branch: refs/heads/route-events
Commit: 018d114c904f6458f07ce3490c5860c61a88de6c
Parents: 2c586f7
Author: Johannes J. Schmidt <schmidt@netzmerk.com>
Authored: Thu Mar 28 00:11:26 2013 +0100
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Thu May 9 09:59:55 2013 +0200

----------------------------------------------------------------------
 share/www/script/test/update_documents.js |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/018d114c/share/www/script/test/update_documents.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/update_documents.js b/share/www/script/test/update_documents.js
index 32ec72e..8684217 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"}


Mime
View raw message