Permalink
Browse files

Get existing tests working again.

  • Loading branch information...
1 parent 5d9f873 commit d65f4fc981a9ad39f965e3e47f07926aab31f798 @mmcgrana committed Feb 28, 2010
View
7 ring-core/src/ring/middleware/file.clj
@@ -2,7 +2,8 @@
(:use (clojure.contrib [def :only (defvar-)]
[except :only (throw-if-not)])
ring.util.response)
- (:require (ring.util [codec :as codec])))
+ (:require (ring.util [codec :as codec]))
+ (:import java.io.File))
(defn- str-includes?
"Returns logical truth iff the given target appears in the given string"
@@ -15,7 +16,7 @@
returning."
[dir]
(let [#^File fdir (if (string? dir) (File. #^String dir) dir)]
- (ex/throw-if-not (.exists fdir)
+ (throw-if-not (.exists fdir)
"Directory does not exist: %s" fdir)
fdir))
@@ -47,6 +48,6 @@
(re-find #"\.[a-z]+$" uri) uri
:else (str uri ".html"))]
(if-let [file (maybe-file fdir path)]
- (respond file)
+ (response file)
(app req)))))
(app req)))))
View
3 ring-core/src/ring/util/file.clj
@@ -1,4 +1,5 @@
-(ns ring.util.file)
+(ns ring.util.file
+ (:import java.io.File))
(defn safe-path?
"Is a filepath safe for a particular root?"
View
8 ring-core/src/ring/util/response.clj
@@ -5,15 +5,15 @@
(defn redirect
"Returns a Ring response for an HTTP 302 redirect."
- [url & [opts]]
+ [url]
{:status 302
:headers {"Location" url}
:body ""})
(defn response
"Returns a skeletal Ring response with the given body, status of 200, and no
headers."
- [body & [opts]]
+ [body]
{:status 200
:body body
:headers {}})
@@ -35,8 +35,8 @@
[resp status]
(assoc resp :status status))
-(def content-type
- "Returns an update Ring response with the a Content-Type header corresponding
+(defn content-type
+ "Returns an updated Ring response with the a Content-Type header corresponding
to the given content-type."
[resp content-type]
(assoc-in resp [:headers "Content-Type"] content-type))
View
6 ring-core/test/ring/util/response_test.clj
@@ -2,8 +2,6 @@
(:use clojure.test
ring.util.response))
-(deftest test-redirects-to
+(deftest test-redirect
(is (= {:status 302 :headers {"Location" "http://google.com"} :body ""}
- (redirect-to "http://google.com")))
- (is (= {:status 303 :headers {"Location" "http://google.com"} :body ""}
- (redirect-to "http://google.com" {:status 303}))))
+ (redirect "http://google.com"))))

0 comments on commit d65f4fc

Please sign in to comment.