Let's say I have a controller action some_action/2 which redirects to /a-path. I need to write a unit test which asserts if the connection is redirected to /a-path. How to do that in Pheonix.
Let's say I have a controller action some_action/2 which redirects to /a-path. I need to write a unit test which asserts if the connection is redirected to /a-path. How to do that in Pheonix.
Use redirected_to function to assert if the connection is redirected to a particular path, as the following example.
test "redirects to the path /a-path", %{conn: conn, user: user} do
new_conn = some_action(conn, %{})
assert redirected_to(new_conn) == "/a-path"
end