diff options
-rw-r--r-- | share/www/script/test/show_documents.js | 18 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_show.erl | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js index f4aa62a7..c755898e 100644 --- a/share/www/script/test/show_documents.js +++ b/share/www/script/test/show_documents.js @@ -44,6 +44,11 @@ couchTests.show_documents = function(debug) { }; } }), + "json" : stringFun(function(doc, req) { + return { + json : doc + } + }), "req-info" : stringFun(function(doc, req) { return { json : req @@ -300,4 +305,17 @@ couchTests.show_documents = function(debug) { }); T(xhr.getResponseHeader("Content-Type") == "text/html"); T(xhr.responseText == "Ha ha, you said \"plankton\"."); + + // test inclusion of conflict state + var doc1 = {_id:"foo", a:1}; + var doc2 = {_id:"foo", a:2}; + db.save(doc1); + + //create the conflict with a all_or_nothing bulk docs request + var docs = [doc2]; + db.bulkSave(docs, {all_or_nothing:true}); + + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/json/foo"); + TEquals(1, JSON.parse(xhr.responseText)._conflicts.length); + }; diff --git a/src/couchdb/couch_httpd_show.erl b/src/couchdb/couch_httpd_show.erl index dd337ced..5aed8971 100644 --- a/src/couchdb/couch_httpd_show.erl +++ b/src/couchdb/couch_httpd_show.erl @@ -30,7 +30,7 @@ handle_doc_show_req(#httpd{ #doc{body={Props}} = couch_httpd_db:couch_doc_open(Db, DesignId, nil, []), Lang = proplists:get_value(<<"language">>, Props, <<"javascript">>), ShowSrc = get_nested_json_value({Props}, [<<"shows">>, ShowName]), - Doc = try couch_httpd_db:couch_doc_open(Db, DocId, nil, []) of + Doc = try couch_httpd_db:couch_doc_open(Db, DocId, nil, [conflicts]) of FoundDoc -> FoundDoc catch _ -> nil |