summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-02-25 01:20:07 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-02-25 01:20:07 +0000
commit16577da96d0cb43b7733a3a04c21aa9ac72bdb64 (patch)
tree6272012e5de13625259894bc699d568a1a3cb90b /share/www
parent4bc9bfa958d7107e2667cde9d671fd189301d4bf (diff)
commonjs require for show list etc via Mikeal Rogers. closes COUCHDB-658
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@916076 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/test/design_docs.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/share/www/script/test/design_docs.js b/share/www/script/test/design_docs.js
index 9318d2bc..efc2e718 100644
--- a/share/www/script/test/design_docs.js
+++ b/share/www/script/test/design_docs.js
@@ -38,6 +38,13 @@ function() {
var designDoc = {
_id:"_design/test", // turn off couch.js id escaping?
language: "javascript",
+ whatever : {
+ stringzone : "exports.string = 'plankton';",
+ commonjs : {
+ whynot : "exports.test = require('../stringzone')",
+ upper : "exports.testing = require('./whynot').test.string.toUpperCase()"
+ }
+ },
views: {
all_docs_twice: {map: "function(doc) { emit(doc.integer, null); emit(doc.integer, null) }"},
no_docs: {map: "function(doc) {}"},
@@ -50,9 +57,11 @@ function() {
reduce:"function (keys, values) { return \"" + makebigstring(16) + "\"; };"}
},
shows: {
- simple: "function() {return 'ok'};"
+ simple: "function() {return 'ok'};",
+ requirey : "function() { var lib = require('whatever/commonjs/upper'); return lib.testing; };"
}
- }
+ };
+
var xhr = CouchDB.request("PUT", "/test_suite_db_a/_design/test", {body: JSON.stringify(designDoc)});
var resp = JSON.parse(xhr.responseText);
@@ -74,6 +83,11 @@ function() {
T(xhr.status == 200);
TEquals("ok", xhr.responseText, 'query server used wrong ddoc');
+ // test commonjs require
+ var xhr = CouchDB.request("GET", "/test_suite_db/_design/test/_show/requirey");
+ T(xhr.status == 200);
+ TEquals("PLANKTON", xhr.responseText);
+
// test that we get design doc info back
var dinfo = db.designInfo("_design/test");
TEquals("test", dinfo.name);