diff --git a/test/app_web/controllers/page_controller_test.exs b/test/app_web/controllers/page_controller_test.exs index be2fb57d..c4f82e8a 100644 --- a/test/app_web/controllers/page_controller_test.exs +++ b/test/app_web/controllers/page_controller_test.exs @@ -6,7 +6,7 @@ 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" => "test@email.com", "password" => "p"}} conn = post(conn, Routes.page_path(conn, :register), params) @@ -14,13 +14,20 @@ defmodule AppWeb.PageControllerTest do 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" => "test@email.com", "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" => "test@email.com", "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