Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add pre route test and fix pre-routes

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
commit 17d284ca6cbee94ab8abef29999d5c3fd7b1d283 1 parent fe06593
@ibdknox ibdknox authored
Showing with 17 additions and 3 deletions.
  1. +3 −3 src/noir/core.clj
  2. +14 −0 test/noir/test/core.clj
View
6 src/noir/core.clj
@@ -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
14 test/noir/test/core.clj
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.