You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jh...@apache.org on 2012/02/29 12:09:58 UTC

[3/9] git commit: More thorough vhost and rewrite testing

More thorough vhost and rewrite testing


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

Branch: refs/heads/COUCHDB-1416
Commit: 33db9434bef7e34ebc92278752c5b1325ce9ed0d
Parents: 1bc8c49
Author: Jason Smith (air) <jh...@apache.org>
Authored: Wed Feb 29 10:15:09 2012 +0000
Committer: Jason Smith (air) <jh...@apache.org>
Committed: Wed Feb 29 10:15:09 2012 +0000

----------------------------------------------------------------------
 share/www/script/test/rewrite.js |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/33db9434/share/www/script/test/rewrite.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/rewrite.js b/share/www/script/test/rewrite.js
index 0262bb6..c69c216 100644
--- a/share/www/script/test/rewrite.js
+++ b/share/www/script/test/rewrite.js
@@ -443,8 +443,13 @@ couchTests.rewrite = function(debug) {
     var rw_ddoc = {
       _id: "_design/rwtest",
       rewrites: [
+          {"from":"testShow", "to":"_show/show_requested_path"},
           {"from":"path/testShow","to":"_show/show_requested_path"},
-          {"from":"_config/*","to":"../../../_config/*"}
+          {"from":"_config/*","to":"../../../_config/*"},
+
+          {"from":"one", "to":"_rewrite/two"},
+          {"from":"two", "to":"_rewrite/three"},
+          {"from":"three", "to":"_rewrite/testShow"}
       ],
       shows : {
           show_requested_path : stringFun(function(doc, req){
@@ -456,7 +461,11 @@ couchTests.rewrite = function(debug) {
     T(db.save(rw_ddoc).ok);
 
     // try accessing directly
-    var res = CouchDB.request("GET", "/test_suite_db/_design/rwtest/_rewrite/path/testShow");
+    var res = CouchDB.request("GET", "/test_suite_db/_design/rwtest/_rewrite/testShow");
+    TEquals('/test_suite_db/_design/rwtest/_rewrite/testShow',
+            res.responseText, "requested_path should equal requested");
+
+    res = CouchDB.request("GET", "/test_suite_db/_design/rwtest/_rewrite/path/testShow");
     TEquals('/test_suite_db/_design/rwtest/_rewrite/path/testShow',
             res.responseText, "requested_path should equal requested");
 
@@ -468,6 +477,13 @@ couchTests.rewrite = function(debug) {
     run_on_modified_server([vhosts], function() {
       var res = CouchDB.request("GET", "/path/testShow");
       TEquals('/path/testShow', res.responseText, "requested_path should equal requested");
+
+      res = CouchDB.request("GET", "/testShow");
+      TEquals('/testShow', res.responseText, "requested_path should equal requested");
+
+      // Test multiple rewrites.
+      res = CouchDB.request("GET", "/one");
+      TEquals("/one", res.responseText, "requested_path works through multiple rewrites");
     });
 
     // Test a vhost to a path within the rewrite namespace.