mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
you know what, let's make tests pass
This commit is contained in:
parent
2edc80bd7c
commit
2bf13011cc
6 changed files with 20 additions and 20 deletions
|
@ -27,7 +27,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
assert Repo.get_by!(Users.UserToken, user_id: user.id).context == "confirm"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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)
|
refute Repo.get_by(Users.UserToken, user_id: user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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) == []
|
assert Repo.all(Users.UserToken) == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -73,7 +73,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do
|
||||||
conn = get(conn, ~p"/confirmations/#{token}")
|
conn = get(conn, ~p"/confirmations/#{token}")
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
"Confirmation link is invalid or it has expired"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do
|
||||||
conn = get(conn, ~p"/confirmations/oops")
|
conn = get(conn, ~p"/confirmations/oops")
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
"Confirmation link is invalid or it has expired"
|
||||||
|
|
||||||
refute Users.get_user!(user.id).confirmed_at
|
refute Users.get_user!(user.id).confirmed_at
|
||||||
|
|
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
assert Repo.get_by!(Users.UserToken, user_id: user.id).context == "reset_password"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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) == []
|
assert Repo.all(Users.UserToken) == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do
|
||||||
conn = get(conn, ~p"/passwords/oops/edit")
|
conn = get(conn, ~p"/passwords/oops/edit")
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
"Reset password link is invalid or it has expired"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -109,7 +109,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do
|
||||||
conn = put(conn, ~p"/passwords/oops")
|
conn = put(conn, ~p"/passwords/oops")
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
"Reset password link is invalid or it has expired"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/registrations/edit"
|
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)
|
assert Users.get_user_by_email(user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do
|
||||||
conn = get(conn, ~p"/registrations/email/#{token}")
|
conn = get(conn, ~p"/registrations/email/#{token}")
|
||||||
assert redirected_to(conn) == ~p"/registrations/edit"
|
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"
|
"Email change link is invalid or it has expired"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do
|
||||||
conn = get(conn, ~p"/registrations/email/oops")
|
conn = get(conn, ~p"/registrations/email/oops")
|
||||||
assert redirected_to(conn) == ~p"/registrations/edit"
|
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"
|
"Email change link is invalid or it has expired"
|
||||||
|
|
||||||
assert Users.get_user_by_email(user.email)
|
assert Users.get_user_by_email(user.email)
|
||||||
|
|
|
@ -33,8 +33,8 @@ defmodule PhilomenaWeb.SessionControllerTest do
|
||||||
conn = get(conn, "/registrations/edit")
|
conn = get(conn, "/registrations/edit")
|
||||||
response = html_response(conn, 200)
|
response = html_response(conn, 200)
|
||||||
assert response =~ user.email
|
assert response =~ user.email
|
||||||
assert response =~ "Settings</a>"
|
assert response =~ "Settings</div>"
|
||||||
assert response =~ "Logout</a>"
|
assert response =~ "Logout</div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "logs the user in with remember me", %{conn: conn, user: user} do
|
test "logs the user in with remember me", %{conn: conn, user: user} do
|
||||||
|
|
|
@ -27,7 +27,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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"
|
assert Repo.get_by!(Users.UserToken, user_id: user.id).context == "unlock"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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)
|
refute Repo.get_by(Users.UserToken, user_id: user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
assert redirected_to(conn) == "/"
|
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) == []
|
assert Repo.all(Users.UserToken) == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -72,13 +72,13 @@ defmodule PhilomenaWeb.UnlockControllerTest do
|
||||||
|
|
||||||
conn = get(conn, ~p"/unlocks/#{token}")
|
conn = get(conn, ~p"/unlocks/#{token}")
|
||||||
assert redirected_to(conn) == "/"
|
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
|
end
|
||||||
|
|
||||||
test "does not unlock with invalid token", %{conn: conn, user: user} do
|
test "does not unlock with invalid token", %{conn: conn, user: user} do
|
||||||
conn = get(conn, ~p"/unlocks/oops")
|
conn = get(conn, ~p"/unlocks/oops")
|
||||||
assert redirected_to(conn) == "/"
|
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
|
assert Users.get_user!(user.id).locked_at
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,7 +164,7 @@ defmodule PhilomenaWeb.UserAuthTest do
|
||||||
assert conn.halted
|
assert conn.halted
|
||||||
assert redirected_to(conn) == ~p"/sessions/new"
|
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."
|
"You must log in to access this page."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue