couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r917553 - in /couchdb/trunk: src/couchdb/couch_httpd.erl test/etap/160-vhosts.t
Date Mon, 01 Mar 2010 14:57:28 GMT
Author: benoitc
Date: Mon Mar  1 14:57:28 2010
New Revision: 917553

URL: http://svn.apache.org/viewvc?rev=917553&view=rev
Log:
fix issue COUCHDB-678 applying patch from Filipe Manana.

Modified:
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/test/etap/160-vhosts.t

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=917553&r1=917552&r2=917553&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Mon Mar  1 14:57:28 2010
@@ -137,7 +137,7 @@
 redirect_to_vhost(MochiReq, DefaultFun,
     UrlHandlers, DbUrlHandlers, DesignUrlHandlers, VhostTarget) ->
 
-    Path = MochiReq:get(path),
+    Path = MochiReq:get(raw_path),
     Target = VhostTarget ++ Path,
     ?LOG_DEBUG("Vhost Target: '~p'~n", [Target]),
     % build a new mochiweb request

Modified: couchdb/trunk/test/etap/160-vhosts.t
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/160-vhosts.t?rev=917553&r1=917552&r2=917553&view=diff
==============================================================================
--- couchdb/trunk/test/etap/160-vhosts.t (original)
+++ couchdb/trunk/test/etap/160-vhosts.t Mon Mar  1 14:57:28 2010
@@ -35,8 +35,15 @@
     conn = nil
 }).
 
+-record(user_ctx, {
+    name = null,
+    roles = [],
+    handler
+}).
+
 server() -> "http://127.0.0.1:5984/".
 dbname() -> "etap-test-db".
+admin_user_ctx() -> {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
 
 config_files() ->
     lists:map(fun test_util:build_file/1, [
@@ -47,7 +54,7 @@
 main(_) ->
     test_util:init_code_path(),
 
-    etap:plan(2),
+    etap:plan(3),
     case (catch test()) of
         ok ->
             etap:end_tests();
@@ -62,14 +69,22 @@
     ibrowse:start(),
     crypto:start(),
 
-    couch_server:delete(list_to_binary(dbname()), []),
-    {ok, Db} = couch_db:create(list_to_binary(dbname()), []),
+    couch_server:delete(list_to_binary(dbname()), [admin_user_ctx()]),
+    {ok, Db} = couch_db:create(list_to_binary(dbname()), [admin_user_ctx()]),
+
+    Doc = couch_doc:from_json_obj({[
+        {<<"_id">>, <<"doc1">>},
+        {<<"value">>, 666}
+    ]}),
+    {ok, _} = couch_db:update_docs(Db, [Doc]),
+    couch_db:ensure_full_commit(Db),
 
     %% end boilerplate, start test
 
     couch_config:set("vhosts", "example.com", "/etap-test-db", false),
     test_regular_request(),
     test_vhost_request(),
+    test_vhost_request_with_qs(),
 
     %% restart boilerplate
     couch_db:close(Db),
@@ -94,3 +109,13 @@
             etap:is(true, true, "should return database info");
         _Else -> false
     end.
+
+test_vhost_request_with_qs() ->
+    Url = server() ++ "doc1?revs_info=true",
+    case ibrowse:send_req(Url, [], get, [], [{host_header, "example.com"}]) of
+        {ok, _, _, Body} ->
+            {JsonProps} = couch_util:json_decode(Body),
+            HasRevsInfo = proplists:is_defined(<<"_revs_info">>, JsonProps),
+            etap:is(HasRevsInfo, true, "should return _revs_info");
+        _Else -> false
+    end.



Mime
View raw message