39 lines
1.2 KiB
Elixir
39 lines
1.2 KiB
Elixir
defmodule FriendsWeb.PageControllerTest do
|
|
use FriendsWeb.ConnCase, async: true
|
|
import Friends.{AccountsFixtures, FriendsFixtures}
|
|
|
|
alias FriendsWeb.Router.Helpers, as: Routes
|
|
|
|
setup do
|
|
%{user: user_fixture()}
|
|
end
|
|
|
|
describe "GET '/'" do
|
|
test "shows the landing page if not logged in", %{conn: conn} do
|
|
conn = get(conn, "/")
|
|
assert html_response(conn, 200) =~ "Friends App"
|
|
assert html_response(conn, 200) =~ "Log in"
|
|
assert html_response(conn, 200) =~ "Register"
|
|
end
|
|
|
|
test "redirects to the new profile flow if logged in but has no profile", %{
|
|
conn: conn,
|
|
user: user
|
|
} do
|
|
_friend = friend_fixture(%{email: "random_email@invalid.biz"})
|
|
conn = conn |> log_in_user(user) |> get("/")
|
|
assert redirected_to(conn) == Routes.friends_edit_path(conn, :overview, :new)
|
|
assert get_flash(conn, :info) =~ "profile!"
|
|
end
|
|
|
|
test "redirects to the friends dashboard if logged in & has a profile", %{
|
|
conn: conn,
|
|
user: user
|
|
} do
|
|
_friend = friend_fixture(%{email: user.email})
|
|
conn = conn |> log_in_user(user) |> get("/")
|
|
assert redirected_to(conn) == Routes.friends_path(conn, :index)
|
|
end
|
|
end
|
|
end
|