From 112f8620568a6b8d56d00172cd8f8e10d9c1041a Mon Sep 17 00:00:00 2001 From: Glen Mailer Date: Tue, 14 May 2013 09:17:04 +0100 Subject: [PATCH] Fix for specifying querystring without extra params The bug was introduced in the move to ring-codec as the nil behaviour differed in form-encode --- src/ring/mock/request.clj | 3 ++- test/ring/mock/test/request.clj | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ring/mock/request.clj b/src/ring/mock/request.clj index 926c64f..388f365 100644 --- a/src/ring/mock/request.clj +++ b/src/ring/mock/request.clj @@ -9,7 +9,8 @@ (defn- encode-params "Turn a map of parameters into a urlencoded string." [params] - (codec/form-encode params)) + (if params + (codec/form-encode params))) (defn header "Add a HTTP header to the request map." diff --git a/test/ring/mock/test/request.clj b/test/ring/mock/test/request.clj index e8a771b..ab9a776 100644 --- a/test/ring/mock/test/request.clj +++ b/test/ring/mock/test/request.clj @@ -35,6 +35,9 @@ (is (= (slurp body) "quux=zot")))) (testing "nil path" (is (= (:uri (request :get "http://example.com")) "/"))) + (testing "only params in :get" + (is (= (:query-string (request :get "/?a=b")) + "a=b"))) (testing "added params in :get" (is (= (:query-string (request :get "/" (array-map :x "y" :z "n"))) "x=y&z=n"))