From 8c2ee9751a1d462d5bdc8648e1cd10b94c9c03eb Mon Sep 17 00:00:00 2001 From: James Reeves Date: Wed, 29 Dec 2010 11:50:08 +0000 Subject: [PATCH] Fixed file and resource routes --- src/compojure/route.clj | 4 ++-- test/compojure/test/route.clj | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compojure/route.clj b/src/compojure/route.clj index 23772870..98154c85 100644 --- a/src/compojure/route.clj +++ b/src/compojure/route.clj @@ -13,7 +13,7 @@ keys: :root - the root path where the files are stored. Defaults to 'public'." [path & [options]] - (GET (add-wildcard path) {{file-path "*"} :params} + (GET (add-wildcard path) {{file-path :*} :route-params} (let [options (merge {:root "public"} options)] (file-response file-path options)))) @@ -22,7 +22,7 @@ keys: :root - the root prefix to get the resources from. Defaults to '/public'." [path & [options]] - (GET (add-wildcard path) {{resource-path "*"} :params} + (GET (add-wildcard path) {{resource-path :*} :route-params} (let [options (merge {:root "/public"} options)] (resource-response resource-path options)))) diff --git a/test/compojure/test/route.clj b/test/compojure/test/route.clj index 08c80825..614bd62a 100644 --- a/test/compojure/test/route.clj +++ b/test/compojure/test/route.clj @@ -1,15 +1,16 @@ (ns compojure.test.route (:use clojure.test + ring.mock.request [clojure.contrib.io :only (slurp*)]) (:require [compojure.route :as route])) (deftest not-found-route - (let [response ((route/not-found "foo") {})] + (let [response ((route/not-found "foo") (request :get "/"))] (is (= (:status response) 404)) (is (= (:body response) "foo")))) (deftest resources-route (let [route (route/resources "/foo" {:root "/resources"}) - response (route {:request-method :get, :uri "/foo/test.txt"})] + response (route (request :get "/foo/test.txt"))] (is (= (:status response) 200)) (is (= (slurp* (:body response)) "foobar\n"))))