diff options
author | Jan Lehnardt <jan@apache.org> | 2010-02-04 23:09:06 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2010-02-04 23:09:06 +0000 |
commit | ff1618779bc85d8f16d6aeebec461fad51b008c5 (patch) | |
tree | 253733cda59e10beb486b4903d43f21f795d227c /share/www/script | |
parent | a75bc7b281952eed8dda9e0c09e3fe386bbe9f32 (diff) |
re-enable 404 handling in show functions while retaining user-friendly error behaviour
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@906721 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/test/show_documents.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js index bdb1b73e..2e895838 100644 --- a/share/www/script/test/show_documents.js +++ b/share/www/script/test/show_documents.js @@ -22,10 +22,15 @@ couchTests.show_documents = function(debug) { shows: { "hello" : stringFun(function(doc, req) { log("hello fun"); + log(req); if (doc) { return "Hello World"; } else { - return "Empty World"; + if(req.id) { + return "New World"; + } else { + return "Empty World"; + } } }), "just-name" : stringFun(function(doc, req) { @@ -56,6 +61,9 @@ couchTests.show_documents = function(debug) { "empty" : stringFun(function(doc, req) { return ""; }), + "fail" : stringFun(function(doc, req) { + return doc._id; + }), "xml-type" : stringFun(function(doc, req) { return { "headers" : { @@ -161,7 +169,7 @@ couchTests.show_documents = function(debug) { T(xhr.responseText == ""); // // hello template world (non-existing docid) - xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello/nonExistingDoc"); + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/fail/nonExistingDoc"); T(xhr.status == 404); var resp = JSON.parse(xhr.responseText); T(resp.error == "not_found"); @@ -173,8 +181,7 @@ couchTests.show_documents = function(debug) { // show with missing doc xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/just-name/missingdoc"); T(xhr.status == 404); - var resp = JSON.parse(xhr.responseText); - T(resp.error == "not_found"); + TEquals("No such doc", xhr.responseText); // show with missing func xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/missing/"+docid); @@ -350,5 +357,10 @@ couchTests.show_documents = function(debug) { db.save(doc3); xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/withSlash/a/b/c"); T(xhr.status == 200); + + // hello template world (non-existing docid) + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello/nonExistingDoc"); + T(xhr.responseText == "New World"); + }; |