Skip to content

Commit

Permalink
add test for logout route, #119
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed Dec 12, 2019
1 parent a24f842 commit 38bd01f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/app_web/controllers/page_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ defmodule AppWeb.PageControllerTest do
assert html_response(conn, 200) =~ "effectiveness"
end

describe "login/register" do
describe "login/register and logout" do
test "display error when password invalid", %{conn: conn} do
params = %{"person" => %{"email" => "[email protected]", "password" => "p"}}
conn = post(conn, Routes.page_path(conn, :register), params)

assert html_response(conn, 200) =~ "should be at least 6 character(s)"
end

test "redirects to home", %{conn: conn} do
test "redirects to user info page when already logged in", %{conn: conn} do
params = %{"person" => %{"email" => "[email protected]", "password" => "password"}}
conn = post(conn, Routes.page_path(conn, :register), params)

assert redirected_to(conn, 302) =~ "/people/info"
end

test "on logout redirect to index (ie / ) page", %{conn: conn} do
params = %{"person" => %{"email" => "[email protected]", "password" => "password"}}
conn = post(conn, Routes.page_path(conn, :register), params)
conn = get(conn, Routes.person_path(conn, :logout))
assert redirected_to(conn, 302) =~ "/"
end
end


end

0 comments on commit 38bd01f

Please sign in to comment.