diff options
author | Christopher Lenz <cmlenz@apache.org> | 2008-09-09 11:12:36 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@apache.org> | 2008-09-09 11:12:36 +0000 |
commit | 37ca97c918f4b5316e4293d8f1001bb87b8dfb0c (patch) | |
tree | e26fda143521e2fa2935ba657d8f00f22c3e5d9a /share/www/script/couch_tests.js | |
parent | b8e510ba813f9b5a24483e16dd6a9971b31dc876 (diff) |
Fix for attachment content-type conversion from/to binary in RESTful API.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@693435 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch_tests.js')
-rw-r--r-- | share/www/script/couch_tests.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index b35e66ce..3d061ed5 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -682,10 +682,9 @@ var tests = { T(xhr.responseText == "This is a base64 encoded text"); T(xhr.getResponseHeader("Content-Type") == "text/plain"); - // empty attachment var binAttDoc2 = { - _id: "bin_doc5", + _id: "bin_doc2", _attachments:{ "foo.txt": { content_type:"text/plain", @@ -696,19 +695,26 @@ var tests = { T(db.save(binAttDoc2).ok); - var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc5/foo.txt"); + var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc2/foo.txt"); T(xhr.responseText.length == 0); T(xhr.getResponseHeader("Content-Type") == "text/plain"); - + // test RESTful doc API - - var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc2/foo2.txt", { + + var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc2/foo2.txt?rev=" + binAttDoc2._rev, { body:"This is no base64 encoded text", headers:{"Content-Type": "text/plain;charset=utf-8"} }); T(xhr.status == 201); var rev = JSON.parse(xhr.responseText).rev; - + + binAttDoc2 = db.open("bin_doc2"); + console.log(JSON.stringify(binAttDoc2)); + T(binAttDoc2._attachments["foo.txt"] !== undefined); + T(binAttDoc2._attachments["foo2.txt"] !== undefined); + T(binAttDoc2._attachments["foo2.txt"].content_type == "text/plain;charset=utf-8"); + T(binAttDoc2._attachments["foo2.txt"].length == 30); + var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc2/foo2.txt"); T(xhr.responseText == "This is no base64 encoded text"); T(xhr.getResponseHeader("Content-Type") == "text/plain;charset=utf-8"); |