more easy test fixes

This commit is contained in:
Lili (Tlapka) 2021-10-13 12:18:37 +02:00
parent de5e5009ed
commit 6c6810b96e
4 changed files with 11 additions and 11 deletions

View File

@ -46,7 +46,7 @@ defmodule PokemonCoutureWeb.UserConfirmationControllerTest do
test "does not send confirmation token if email is invalid", %{conn: conn} do
conn =
post(conn, Routes.user_confirmation_path(conn, :create), %{
"user" => %{"email" => "unknown@example.com"}
"user" => %{"username" => "unknown"}
})
assert redirected_to(conn) == "/"

View File

@ -21,11 +21,11 @@ defmodule PokemonCoutureWeb.UserRegistrationControllerTest do
describe "POST /users/register" do
@tag :capture_log
test "creates account and logs the user in", %{conn: conn} do
email = unique_user_email()
username = unique_username()
conn =
post(conn, Routes.user_registration_path(conn, :create), %{
"user" => valid_user_attributes(email: email)
"user" => valid_user_attributes(username: username)
})
assert get_session(conn, :user_token)
@ -34,7 +34,7 @@ defmodule PokemonCoutureWeb.UserRegistrationControllerTest do
# Now do a logged in request and assert on the menu
conn = get(conn, "/")
response = html_response(conn, 200)
assert response =~ email
assert response =~ username
assert response =~ "Settings</a>"
assert response =~ "Log out</a>"
end

View File

@ -22,7 +22,7 @@ defmodule PokemonCoutureWeb.UserResetPasswordControllerTest do
test "sends a new reset password token", %{conn: conn, user: user} do
conn =
post(conn, Routes.user_reset_password_path(conn, :create), %{
"user" => %{"email" => user.email}
"user" => %{"username" => user.username}
})
assert redirected_to(conn) == "/"

View File

@ -26,7 +26,7 @@ defmodule PokemonCoutureWeb.UserSessionControllerTest do
test "logs the user in", %{conn: conn, user: user} do
conn =
post(conn, Routes.user_session_path(conn, :create), %{
"user" => %{"email" => user.email, "password" => valid_user_password()}
"user" => %{"username" => user.username, "password" => valid_user_password()}
})
assert get_session(conn, :user_token)
@ -35,7 +35,7 @@ defmodule PokemonCoutureWeb.UserSessionControllerTest do
# Now do a logged in request and assert on the menu
conn = get(conn, "/")
response = html_response(conn, 200)
assert response =~ user.email
assert response =~ user.username
assert response =~ "Settings</a>"
assert response =~ "Log out</a>"
end
@ -44,7 +44,7 @@ defmodule PokemonCoutureWeb.UserSessionControllerTest do
conn =
post(conn, Routes.user_session_path(conn, :create), %{
"user" => %{
"email" => user.email,
"username" => user.username,
"password" => valid_user_password(),
"remember_me" => "true"
}
@ -60,7 +60,7 @@ defmodule PokemonCoutureWeb.UserSessionControllerTest do
|> init_test_session(user_return_to: "/foo/bar")
|> post(Routes.user_session_path(conn, :create), %{
"user" => %{
"email" => user.email,
"username" => user.username,
"password" => valid_user_password()
}
})
@ -71,12 +71,12 @@ defmodule PokemonCoutureWeb.UserSessionControllerTest do
test "emits error message with invalid credentials", %{conn: conn, user: user} do
conn =
post(conn, Routes.user_session_path(conn, :create), %{
"user" => %{"email" => user.email, "password" => "invalid_password"}
"user" => %{"username" => user.username, "password" => "invalid_password"}
})
response = html_response(conn, 200)
assert response =~ "<h1>Log in</h1>"
assert response =~ "Invalid email or password"
assert response =~ "Invalid username or password"
end
end