Skip to content

Commit

Permalink
Ensure that render retains the metadata on any provided response map
Browse files Browse the repository at this point in the history
  • Loading branch information
cemerick committed Dec 14, 2012
1 parent 66e9573 commit 4729b4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/compojure/response.clj
Expand Up @@ -20,7 +20,8 @@
(content-type "text/html; charset=utf-8")))
APersistentMap
(render [resp-map _]
(merge (response "") resp-map))
(merge (with-meta (response "") (meta resp-map))
resp-map))
IFn
(render [func request]
(render (func request) request))
Expand Down
7 changes: 6 additions & 1 deletion test/compojure/test/response.clj
Expand Up @@ -40,4 +40,9 @@
(testing "with stream URL"
(let [response (response/render (io/resource "ring/util/response.clj") {})]
(is (instance? InputStream (:body response)))
(is (.contains (slurp (:body response)) "(ns ring.util.response")))))
(is (.contains (slurp (:body response)) "(ns ring.util.response"))))

(testing "with map + metadata"
(let [response (response/render ^{:has-metadata? true} {:body "foo"} {})]
(is (= (:body response) "foo"))
(is (= (meta response) {:has-metadata? true})))))

0 comments on commit 4729b4e

Please sign in to comment.