From 2bf13011cc304e93b981c0b22a5cddaef2273af5 Mon Sep 17 00:00:00 2001 From: "Luna D." Date: Thu, 13 Jun 2024 00:27:08 +0200 Subject: [PATCH] you know what, let's make tests pass --- .../controllers/confirmation_controller_test.exs | 10 +++++----- .../controllers/password_controller_test.exs | 8 ++++---- .../controllers/registration/email_controller_test.exs | 6 +++--- .../controllers/session_controller_test.exs | 4 ++-- .../controllers/unlock_controller_test.exs | 10 +++++----- test/philomena_web/user_auth_test.exs | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/philomena_web/controllers/confirmation_controller_test.exs b/test/philomena_web/controllers/confirmation_controller_test.exs index 049fd6d1..cc2a8ae4 100644 --- a/test/philomena_web/controllers/confirmation_controller_test.exs +++ b/test/philomena_web/controllers/confirmation_controller_test.exs @@ -27,7 +27,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" assert Repo.get_by!(Users.UserToken, user_id: user.id).context == "confirm" end @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" refute Repo.get_by(Users.UserToken, user_id: user.id) end @@ -51,7 +51,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" assert Repo.all(Users.UserToken) == [] end end @@ -73,7 +73,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do conn = get(conn, ~p"/confirmations/#{token}") assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :error) =~ + assert Flash.get(conn.assigns.flash, :warning) =~ "Confirmation link is invalid or it has expired" end @@ -81,7 +81,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do conn = get(conn, ~p"/confirmations/oops") assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :error) =~ + assert Flash.get(conn.assigns.flash, :warning) =~ "Confirmation link is invalid or it has expired" refute Users.get_user!(user.id).confirmed_at diff --git a/test/philomena_web/controllers/password_controller_test.exs b/test/philomena_web/controllers/password_controller_test.exs index b74cf046..e7f90ed5 100644 --- a/test/philomena_web/controllers/password_controller_test.exs +++ b/test/philomena_web/controllers/password_controller_test.exs @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" assert Repo.get_by!(Users.UserToken, user_id: user.id).context == "reset_password" end @@ -37,7 +37,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" assert Repo.all(Users.UserToken) == [] end end @@ -61,7 +61,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do conn = get(conn, ~p"/passwords/oops/edit") assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :error) =~ + assert Flash.get(conn.assigns.flash, :warning) =~ "Reset password link is invalid or it has expired" end end @@ -109,7 +109,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do conn = put(conn, ~p"/passwords/oops") assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :error) =~ + assert Flash.get(conn.assigns.flash, :warning) =~ "Reset password link is invalid or it has expired" end end diff --git a/test/philomena_web/controllers/registration/email_controller_test.exs b/test/philomena_web/controllers/registration/email_controller_test.exs index 756fea2e..157a7f9f 100644 --- a/test/philomena_web/controllers/registration/email_controller_test.exs +++ b/test/philomena_web/controllers/registration/email_controller_test.exs @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do }) assert redirected_to(conn) == ~p"/registrations/edit" - assert Flash.get(conn.assigns.flash, :info) =~ "A link to confirm your email" + assert Flash.get(conn.assigns.flash, :alert) =~ "A link to confirm your email" assert Users.get_user_by_email(user.email) end @@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do conn = get(conn, ~p"/registrations/email/#{token}") assert redirected_to(conn) == ~p"/registrations/edit" - assert Flash.get(conn.assigns.flash, :error) =~ + assert Flash.get(conn.assigns.flash, :warning) =~ "Email change link is invalid or it has expired" end @@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do conn = get(conn, ~p"/registrations/email/oops") assert redirected_to(conn) == ~p"/registrations/edit" - assert Flash.get(conn.assigns.flash, :error) =~ + assert Flash.get(conn.assigns.flash, :warning) =~ "Email change link is invalid or it has expired" assert Users.get_user_by_email(user.email) diff --git a/test/philomena_web/controllers/session_controller_test.exs b/test/philomena_web/controllers/session_controller_test.exs index 29d8d7f2..6aec2793 100644 --- a/test/philomena_web/controllers/session_controller_test.exs +++ b/test/philomena_web/controllers/session_controller_test.exs @@ -33,8 +33,8 @@ defmodule PhilomenaWeb.SessionControllerTest do conn = get(conn, "/registrations/edit") response = html_response(conn, 200) assert response =~ user.email - assert response =~ "Settings" - assert response =~ "Logout" + assert response =~ "Settings" + assert response =~ "Logout" end test "logs the user in with remember me", %{conn: conn, user: user} do diff --git a/test/philomena_web/controllers/unlock_controller_test.exs b/test/philomena_web/controllers/unlock_controller_test.exs index bc8df85e..43a251e7 100644 --- a/test/philomena_web/controllers/unlock_controller_test.exs +++ b/test/philomena_web/controllers/unlock_controller_test.exs @@ -27,7 +27,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" assert Repo.get_by!(Users.UserToken, user_id: user.id).context == "unlock" end @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" refute Repo.get_by(Users.UserToken, user_id: user.id) end @@ -51,7 +51,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do }) assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :info) =~ "If your email is in our system" + assert Flash.get(conn.assigns.flash, :alert) =~ "If your email is in our system" assert Repo.all(Users.UserToken) == [] end end @@ -72,13 +72,13 @@ defmodule PhilomenaWeb.UnlockControllerTest do conn = get(conn, ~p"/unlocks/#{token}") assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :error) =~ "Unlock link is invalid or it has expired" + assert Flash.get(conn.assigns.flash, :warning) =~ "Unlock link is invalid or it has expired" end test "does not unlock with invalid token", %{conn: conn, user: user} do conn = get(conn, ~p"/unlocks/oops") assert redirected_to(conn) == "/" - assert Flash.get(conn.assigns.flash, :error) =~ "Unlock link is invalid or it has expired" + assert Flash.get(conn.assigns.flash, :warning) =~ "Unlock link is invalid or it has expired" assert Users.get_user!(user.id).locked_at end end diff --git a/test/philomena_web/user_auth_test.exs b/test/philomena_web/user_auth_test.exs index deeaeca7..b66e5046 100644 --- a/test/philomena_web/user_auth_test.exs +++ b/test/philomena_web/user_auth_test.exs @@ -164,7 +164,7 @@ defmodule PhilomenaWeb.UserAuthTest do assert conn.halted assert redirected_to(conn) == ~p"/sessions/new" - assert Phoenix.Flash.get(conn.assigns.flash, :error) == + assert Phoenix.Flash.get(conn.assigns.flash, :warning) == "You must log in to access this page." end