Permalink
Browse files

Fetch aspects before filters

  • Loading branch information...
1 parent 17bd67f commit 8f0411ffd1efd8c9ed8461f07e3993c30339a9b2 @devinus committed Sep 28, 2012
Showing with 26 additions and 1 deletion.
  1. +1 −1 lib/dynamo/router.ex
  2. +25 −0 test/dynamo/router/filters_test.exs
View
2 lib/dynamo/router.ex
@@ -98,8 +98,8 @@ defmodule Dynamo.Router do
use_once Dynamo.Router.Base
use_once Dynamo.Router.Callbacks
- use_once Dynamo.Router.Fetch
use_once Dynamo.Router.Filters
+ use_once Dynamo.Router.Fetch
end
end
end
View
25 test/dynamo/router/filters_test.exs
@@ -90,4 +90,29 @@ defmodule Dynamo.Router.FiltersTest do
assert conn.assigns[:value] == 3
assert conn.status == 200
end
+
+ defmodule ParamFilter do
+ def prepare(conn) do
+ value = conn.params["value"]
+ conn.assign(:value, value)
+ end
+ end
+
+ defmodule ParamsApp do
+ use Dynamo.Router
+
+ fetch [ :params ]
+
+ filter ParamFilter
+
+ get "/foo" do
+ conn.resp(200, "OK")
+ end
+ end
+
+ test "fetch before filter" do
+ conn = process(ParamsApp, :GET, "/foo?value=bar")
+ assert conn.assigns[:value] == "bar"
+ assert conn.status == 200
+ end
end

0 comments on commit 8f0411f

Please sign in to comment.