File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 (:import [java.net URL MalformedURLException]))
77
88(defn- redirect? [response]
9- (#{301 302 303 307 } (:status response)))
9+ (#{201 301 302 303 307 } (:status response)))
1010
1111(defn- get-header-key [response ^String header-name]
1212 (->> response :headers keys
Original file line number Diff line number Diff line change 22 (:use clojure.test
33 ring.middleware.absolute-redirects
44 [ring.mock.request :only [request]]
5- [ring.util.response :only [redirect response content-type]]))
5+ [ring.util.response :only [redirect response content-type created ]]))
66
77(deftest test-wrap-absolute-redirects
88 (testing " relative redirects"
3737 resp (handler (request :get " /" ))]
3838 (is (= (:status resp) 302 ))
3939 (is (= (:headers resp) {" Location" " http://localhost/foo"
40- " Content-Type" " text/plain" })))))
40+ " Content-Type" " text/plain" }))))
41+ (testing " resource creation"
42+ (let [handler (wrap-absolute-redirects (constantly (created " /bar/1" )))
43+ resp (handler (request :post " /bar" ))]
44+ (is (= (:status resp) 201 ))
45+ (is (= (:headers resp) {" Location" " http://localhost/bar/1" })))))
You can’t perform that action at this time.
0 commit comments