Skip to content

Commit

Permalink
Don't ignore coercions that return false
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Jun 19, 2016
1 parent 46384c7 commit d093486
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
(if (vector? bindings)
`(let [~@(vector-bindings bindings request)]
~(if-let [syms (application-symbols bindings)]
`(if (and ~@syms) (do ~@body))
`(if (and ~@(for [s syms] `(not (nil? ~s)))) (do ~@body))
`(do ~@body)))
`(let [~bindings ~request] ~@body)))

Expand Down
2 changes: 2 additions & 0 deletions test/compojure/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
(mock/request :get "/foo/bar")))))
(is (not (nil? ((GET "/foo/:x" [x :<< coercions/as-int] (str x))
(mock/request :get "/foo/100")))))
(is (not (nil? ((GET "/foo/:x" [x :<< #(Boolean/valueOf %)] (str x))
(mock/request :get "/foo/false")))))
(is (nil? ((GET "/foo/:x" [x :<< coercions/as-int] (str x))
(mock/request :get "/foo/bar")))))

Expand Down

0 comments on commit d093486

Please sign in to comment.