- <.form :let={f} for={@changeset} action={Routes.user_setup_path(@conn, :finish)} class="flex flex-col items-center justify-center w-full h-full mx-8 mt-8 sm:mx-0">
+ <.form :let={f} for={@changeset} action={~p"/users/setup"} class="flex flex-col items-center justify-center w-full h-full mx-8 mt-8 sm:mx-0">
<%= gettext("Welcome to Atomic!") %>
👋
diff --git a/test/atomic_web/controllers/user_auth_test.exs b/test/atomic_web/controllers/user_auth_test.exs
index c95f7500f..3eb6526e4 100644
--- a/test/atomic_web/controllers/user_auth_test.exs
+++ b/test/atomic_web/controllers/user_auth_test.exs
@@ -130,7 +130,7 @@ defmodule AtomicWeb.UserAuthTest do
test "redirects if user is not authenticated", %{conn: conn} do
conn = conn |> fetch_flash() |> UserAuth.require_authenticated_user([])
assert conn.halted
- assert redirected_to(conn) == Routes.user_session_path(conn, :new)
+ assert redirected_to(conn) == ~p"/users/log_in"
assert Phoenix.Flash.get(conn.assigns.flash, :error) ==
"You must log in to access this page."
diff --git a/test/atomic_web/controllers/user_change_password_controller_test.exs b/test/atomic_web/controllers/user_change_password_controller_test.exs
index 0b9e6bae9..ee9c2c589 100644
--- a/test/atomic_web/controllers/user_change_password_controller_test.exs
+++ b/test/atomic_web/controllers/user_change_password_controller_test.exs
@@ -8,22 +8,22 @@ defmodule AtomicWeb.UserSettingsControllerTest do
describe "GET /users/change_password" do
test "renders change password page", %{conn: conn} do
- conn = get(conn, Routes.user_change_password_path(conn, :edit))
+ conn = get(conn, ~p"/users/change_password")
response = html_response(conn, 200)
assert response =~ "
Change Password"
end
test "redirects if user is not logged in" do
conn = build_conn()
- conn = get(conn, Routes.user_change_password_path(conn, :edit))
- assert redirected_to(conn) == Routes.user_session_path(conn, :new)
+ conn = get(conn, ~p"/users/change_password")
+ assert redirected_to(conn) == ~p"/users/log_in"
end
end
describe "PUT /users/change_password" do
test "updates the user password and resets tokens", %{conn: conn, user: user} do
new_password_conn =
- put(conn, Routes.user_change_password_path(conn, :update), %{
+ put(conn, ~p"/users/change_password", %{
"action" => "update_password",
"user" => %{
"current_password" => valid_user_password(),
@@ -32,7 +32,7 @@ defmodule AtomicWeb.UserSettingsControllerTest do
}
})
- assert redirected_to(new_password_conn) == Routes.user_change_password_path(conn, :edit)
+ assert redirected_to(new_password_conn) == ~p"/users/change_password"
assert get_session(new_password_conn, :user_token) != get_session(conn, :user_token)
assert Phoenix.Flash.get(new_password_conn.assigns.flash, :info) =~
@@ -43,7 +43,7 @@ defmodule AtomicWeb.UserSettingsControllerTest do
test "does not update password on invalid data", %{conn: conn} do
old_password_conn =
- put(conn, Routes.user_change_password_path(conn, :update), %{
+ put(conn, ~p"/users/change_password", %{
"action" => "update_password",
"user" => %{
"current_password" => "invalid",
diff --git a/test/atomic_web/controllers/user_confirmation_controller_test.exs b/test/atomic_web/controllers/user_confirmation_controller_test.exs
index b8ca01f15..120811301 100644
--- a/test/atomic_web/controllers/user_confirmation_controller_test.exs
+++ b/test/atomic_web/controllers/user_confirmation_controller_test.exs
@@ -11,7 +11,7 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
describe "GET /users/confirm" do
test "renders the resend confirmation page", %{conn: conn} do
- conn = get(conn, Routes.user_confirmation_path(conn, :new))
+ conn = get(conn, ~p"/users/confirm")
response = html_response(conn, 200)
assert response =~ "
Resend confirmation instructions
"
end
@@ -21,7 +21,7 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
@tag :capture_log
test "sends a new confirmation token", %{conn: conn, user: user} do
conn =
- post(conn, Routes.user_confirmation_path(conn, :create), %{
+ post(conn, ~p"/users/confirm", %{
"user" => %{"email" => user.email}
})
@@ -34,7 +34,7 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
Repo.update!(Accounts.User.confirm_changeset(user))
conn =
- post(conn, Routes.user_confirmation_path(conn, :create), %{
+ post(conn, ~p"/users/confirm", %{
"user" => %{"email" => user.email}
})
@@ -45,7 +45,7 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
test "does not send confirmation token if email is invalid", %{conn: conn} do
conn =
- post(conn, Routes.user_confirmation_path(conn, :create), %{
+ post(conn, ~p"/users/confirm", %{
"user" => %{"email" => "unknown@example.com"}
})
@@ -62,7 +62,7 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
Accounts.deliver_user_confirmation_instructions(user, url)
end)
- conn = get(conn, Routes.user_confirmation_path(conn, :edit, token))
+ conn = get(conn, ~p"/users/confirm/#{token}")
assert redirected_to(conn) == "/users/log_in"
assert Phoenix.Flash.get(conn.assigns.flash, :info) =~ "User confirmed successfully"
assert Accounts.get_user!(user.id).confirmed_at
@@ -70,7 +70,7 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
assert Repo.all(Accounts.UserToken) == []
# When not logged in
- conn = get(conn, Routes.user_confirmation_path(conn, :edit, token))
+ conn = get(conn, ~p"/users/confirm/#{token}")
assert redirected_to(conn) == "/users/log_in"
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
@@ -80,14 +80,14 @@ defmodule AtomicWeb.UserConfirmationControllerTest do
conn =
build_conn()
|> log_in_user(user)
- |> get(Routes.user_confirmation_path(conn, :edit, token))
+ |> get(~p"/users/confirm/#{token}")
assert redirected_to(conn) == "/"
refute Phoenix.Flash.get(conn.assigns.flash, :error)
end
test "does not confirm email with invalid token", %{conn: conn, user: user} do
- conn = get(conn, Routes.user_confirmation_path(conn, :edit, "oops"))
+ conn = get(conn, ~p"/users/confirm/oops")
assert redirected_to(conn) == "/users/log_in"
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
diff --git a/test/atomic_web/controllers/user_registration_controller_test.exs b/test/atomic_web/controllers/user_registration_controller_test.exs
index 8a89dd164..a45e290d5 100644
--- a/test/atomic_web/controllers/user_registration_controller_test.exs
+++ b/test/atomic_web/controllers/user_registration_controller_test.exs
@@ -3,7 +3,7 @@ defmodule AtomicWeb.UserRegistrationControllerTest do
describe "GET /users/register" do
test "renders registration page", %{conn: conn} do
- conn = get(conn, Routes.user_registration_path(conn, :new))
+ conn = get(conn, ~p"/users/register")
response = html_response(conn, 200)
assert response =~ "
Register"
assert response =~ "Login"
@@ -11,7 +11,7 @@ defmodule AtomicWeb.UserRegistrationControllerTest do
end
test "redirects if already logged in", %{conn: conn} do
- conn = conn |> log_in_user(insert(:user)) |> get(Routes.user_registration_path(conn, :new))
+ conn = conn |> log_in_user(insert(:user)) |> get(~p"/users/register")
assert redirected_to(conn) == "/"
end
end
@@ -27,7 +27,7 @@ defmodule AtomicWeb.UserRegistrationControllerTest do
}
conn =
- post(conn, Routes.user_registration_path(conn, :create), %{
+ post(conn, ~p"/users/register", %{
"user" => user_attrs
})
diff --git a/test/atomic_web/controllers/user_reset_password_controller_test.exs b/test/atomic_web/controllers/user_reset_password_controller_test.exs
index e7cb85804..5f8cc13d1 100644
--- a/test/atomic_web/controllers/user_reset_password_controller_test.exs
+++ b/test/atomic_web/controllers/user_reset_password_controller_test.exs
@@ -11,7 +11,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
describe "GET /users/reset_password" do
test "renders the reset password page", %{conn: conn} do
- conn = get(conn, Routes.user_reset_password_path(conn, :new))
+ conn = get(conn, ~p"/users/reset_password")
response = html_response(conn, 200)
assert response =~ "Recover Account"
end
@@ -21,7 +21,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
@tag :capture_log
test "sends a new reset password token given a valid email", %{conn: conn, user: user} do
conn =
- post(conn, Routes.user_reset_password_path(conn, :create), %{
+ post(conn, ~p"/users/reset_password", %{
"user" => %{"input" => user.email}
})
@@ -32,7 +32,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
end
test "does not send reset password token if email is invalid", %{conn: conn} do
- post(conn, Routes.user_reset_password_path(conn, :create), %{
+ post(conn, ~p"/users/reset_password", %{
"user" => %{"input" => "unknown@example.com"}
})
@@ -41,7 +41,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
test "sends a new reset password token given a valid slug", %{conn: conn, user: user} do
conn =
- post(conn, Routes.user_reset_password_path(conn, :create), %{
+ post(conn, ~p"/users/reset_password", %{
"user" => %{"input" => user.slug}
})
@@ -52,7 +52,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
end
test "does not send reset password token if slug is invalid", %{conn: conn} do
- post(conn, Routes.user_reset_password_path(conn, :create), %{
+ post(conn, ~p"/users/reset_password", %{
"user" => %{"input" => "unknown"}
})
@@ -71,7 +71,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
end
test "renders reset password", %{conn: conn, token: token} do
- conn = get(conn, Routes.user_reset_password_path(conn, :edit, token))
+ conn = get(conn, ~p"/users/reset_password/#{token}")
assert html_response(conn, 200) =~ "Reset Password"
end
end
@@ -88,14 +88,14 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
test "resets password once", %{conn: conn, user: user, token: token} do
conn =
- put(conn, Routes.user_reset_password_path(conn, :update, token), %{
+ put(conn, ~p"/users/reset_password/#{token}", %{
"user" => %{
"password" => "new valid password",
"password_confirmation" => "new valid password"
}
})
- assert redirected_to(conn) == Routes.user_session_path(conn, :new)
+ assert redirected_to(conn) == ~p"/users/log_in"
refute get_session(conn, :user_token)
assert Phoenix.Flash.get(conn.assigns.flash, :info) =~ "Password changed successfully"
assert Accounts.get_user_by_email_and_password(user.email, "new valid password")
@@ -103,7 +103,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do
test "does not reset password on invalid data", %{conn: conn, token: token} do
conn =
- put(conn, Routes.user_reset_password_path(conn, :update, token), %{
+ put(conn, ~p"/users/reset_password/#{token}", %{
"user" => %{
"password" => "too short",
"password_confirmation" => "does not match"
diff --git a/test/atomic_web/controllers/user_session_controller_test.exs b/test/atomic_web/controllers/user_session_controller_test.exs
index 453635d0d..ebf5a5be8 100644
--- a/test/atomic_web/controllers/user_session_controller_test.exs
+++ b/test/atomic_web/controllers/user_session_controller_test.exs
@@ -9,7 +9,7 @@ defmodule AtomicWeb.UserSessionControllerTest do
describe "GET /users/log_in" do
test "renders log in page", %{conn: conn} do
- conn = get(conn, Routes.user_session_path(conn, :new))
+ conn = get(conn, ~p"/users/log_in")
response = html_response(conn, 200)
assert response =~ "Log
"
@@ -18,7 +18,7 @@ defmodule AtomicWeb.UserSessionControllerTest do
end
test "redirects if already logged in", %{conn: conn, user: user} do
- conn = conn |> log_in_user(user) |> get(Routes.user_session_path(conn, :new))
+ conn = conn |> log_in_user(user) |> get(~p"/users/log_in")
assert redirected_to(conn) == "/"
end
end
@@ -26,7 +26,7 @@ defmodule AtomicWeb.UserSessionControllerTest do
describe "POST /users/log_in" do
test "logs the user in", %{conn: conn, user: user} do
conn =
- post(conn, Routes.user_session_path(conn, :create), %{
+ post(conn, ~p"/users/log_in", %{
"user" => %{"email" => user.email, "password" => valid_user_password()}
})
@@ -41,7 +41,7 @@ defmodule AtomicWeb.UserSessionControllerTest do
test "logs the user in with remember me", %{conn: conn, user: user} do
conn =
- post(conn, Routes.user_session_path(conn, :create), %{
+ post(conn, ~p"/users/log_in", %{
"user" => %{
"email" => user.email,
"password" => valid_user_password(),
@@ -57,7 +57,7 @@ defmodule AtomicWeb.UserSessionControllerTest do
conn =
conn
|> init_test_session(user_return_to: "/foo/bar")
- |> post(Routes.user_session_path(conn, :create), %{
+ |> post(~p"/users/log_in", %{
"user" => %{
"email" => user.email,
"password" => valid_user_password()
@@ -69,7 +69,7 @@ defmodule AtomicWeb.UserSessionControllerTest do
test "emits error message with invalid credentials", %{conn: conn, user: user} do
conn =
- post(conn, Routes.user_session_path(conn, :create), %{
+ post(conn, ~p"/users/log_in", %{
"user" => %{"email" => user.email, "password" => "invalid_password"}
})
@@ -82,14 +82,14 @@ defmodule AtomicWeb.UserSessionControllerTest do
describe "DELETE /users/log_out" do
test "logs the user out", %{conn: conn, user: user} do
- conn = conn |> log_in_user(user) |> delete(Routes.user_session_path(conn, :delete))
+ conn = conn |> log_in_user(user) |> delete(~p"/users/log_out")
assert redirected_to(conn) == "/users/log_in"
refute get_session(conn, :user_token)
assert Phoenix.Flash.get(conn.assigns.flash, :info) =~ "Logged out successfully"
end
test "succeeds even if the user is not logged in", %{conn: conn} do
- conn = delete(conn, Routes.user_session_path(conn, :delete))
+ conn = delete(conn, ~p"/users/log_out")
assert redirected_to(conn) == "/users/log_in"
refute get_session(conn, :user_token)
end
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index 67463acc2..db69e95d8 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -21,16 +21,16 @@ defmodule AtomicWeb.ConnCase do
using do
quote do
+ # The default endpoint for testing
+ @endpoint AtomicWeb.Endpoint
+
+ use AtomicWeb, :verified_routes
+
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import AtomicWeb.ConnCase
import Atomic.Factory
-
- alias AtomicWeb.Router.Helpers, as: Routes
-
- # The default endpoint for testing
- @endpoint AtomicWeb.Endpoint
end
end