Skip to content
Browse files

Ensure that `render` retains the metadata on any provided response map

  • Loading branch information...
1 parent 24fe43a commit 087cbe97f72bb302c7d760625eb4c21d165a4fa8 @cemerick cemerick committed with Dec 14, 2012
Showing with 8 additions and 2 deletions.
  1. +2 −1 src/compojure/response.clj
  2. +6 −1 test/compojure/test/response.clj
View
3 src/compojure/response.clj
@@ -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))
View
7 test/compojure/test/response.clj
@@ -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 087cbe9

Please sign in to comment.
Something went wrong with that request. Please try again.