summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/couch.js4
-rw-r--r--share/www/script/couch_tests.js52
2 files changed, 56 insertions, 0 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index 0a2698ab..96612faa 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -129,6 +129,10 @@ function CouchDB(name, httpHeaders) {
reduceFun = reduceFun.toSource ? reduceFun.toSource() : "(" + reduceFun.toString() + ")";
body.reduce = reduceFun;
}
+ if (options && options.options != undefined) {
+ body.options = options.options;
+ delete options.options;
+ }
this.last_req = this.request("POST", this.uri + "_temp_view" + encodeOptions(options), {
headers: {"Content-Type": "application/json"},
body: JSON.stringify(body)
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 28a1b9f4..8bdebec1 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -773,6 +773,58 @@ var tests = {
}
},
+ design_options: function(debug) {
+ var db = new CouchDB("test_suite_db");
+ db.deleteDb();
+ db.createDb();
+ if (debug) debugger;
+
+ //// test the includes_design option
+ var map = "function (doc) {emit(null, doc._id);}";
+
+ // we need a design doc even to test temp views with it
+ var designDoc = {
+ _id:"_design/fu",
+ language: "javascript",
+ options: {
+ include_design: true
+ },
+ views: {
+ data: {"map": map}
+ }
+ };
+ T(db.save(designDoc).ok);
+
+ // should work for temp views
+ var rows = db.query(map, null, {options:{include_design: true}}).rows;
+ T(rows.length == 1);
+ T(rows[0].value == "_design/fu");
+
+ rows = db.query(map).rows;
+ T(rows.length == 0);
+
+ // when true, should include design docs in views
+ rows = db.view("fu/data").rows;
+ T(rows.length == 1);
+ T(rows[0].value == "_design/fu");
+
+ // when false, should not
+ designDoc.options.include_design = false;
+ delete designDoc._rev;
+ designDoc._id = "_design/bingo";
+ T(db.save(designDoc).ok);
+ rows = db.view("bingo/data").rows;
+ T(rows.length == 0);
+
+ // should default to false
+ delete designDoc.options;
+ delete designDoc._rev;
+ designDoc._id = "_design/bango";
+ T(db.save(designDoc).ok);
+ rows = db.view("bango/data").rows;
+ T(rows.length == 0);
+ },
+
multiple_rows: function(debug) {
var db = new CouchDB("test_suite_db");
db.deleteDb();