Permalink
Browse files

add pre route test and fix pre-routes

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
1 parent fe06593 commit 17d284ca6cbee94ab8abef29999d5c3fd7b1d283 @ibdknox ibdknox committed Aug 11, 2011
Showing with 17 additions and 3 deletions.
  1. +3 −3 src/noir/core.clj
  2. +14 −0 test/noir/test/core.clj
View
@@ -133,6 +133,6 @@
a section based on privileges:
(pre-route '/admin/*' {} (when-not (is-admin?) (redirect '/login')))"
- [route destruct & body]
- (let [{action# :action url# :url} (parse-args route)]
- `(swap! pre-routes assoc ~url# (~action# ~url# {:as request#} ((fn [~destruct] ~@body) request#)))))
+ [& args]
+ (let [{:keys [action destruct url body]} (parse-args args)]
+ `(swap! pre-routes assoc ~url (~action ~url {:as request#} ((fn [~destruct] ~@body) request#)))))
View
@@ -74,12 +74,26 @@
(has-content-type "application/json")
(has-body "{\"json\":\"text\"}")))
+(defpage "/" [])
+
(defpage "/utf" []
"ąčęė")
(defpage foo "/foo" []
"named-route")
+(pre-route "/pre" []
+ (resp/status 403
+ "not allowed"))
+
+(defpage "/pre" []
+ "you should never see this")
+
+(deftest pre-route-test
+ (-> (send-request "/pre")
+ (has-status 403)
+ (has-body "not allowed")))
+
(deftest named-route-test
(-> (send-request "/foo")
(has-status 200)

0 comments on commit 17d284c

Please sign in to comment.