Place our index route under authentication
This commit is contained in:
parent
d0ab24b9e3
commit
8fbeabc208
2 changed files with 15 additions and 7 deletions
|
@ -17,12 +17,6 @@ defmodule RealEstateWeb.Router do
|
|||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", RealEstateWeb do
|
||||
pipe_through :browser
|
||||
|
||||
live "/", PageLive, :index
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
# scope "/api", RealEstateWeb do
|
||||
# pipe_through :api
|
||||
|
@ -66,6 +60,9 @@ defmodule RealEstateWeb.Router do
|
|||
put "/users/settings/update_password", UserSettingsController, :update_password
|
||||
put "/users/settings/update_email", UserSettingsController, :update_email
|
||||
get "/users/settings/confirm_email/:token", UserSettingsController, :confirm_email
|
||||
|
||||
# This line was moved
|
||||
live "/", PageLive, :index
|
||||
end
|
||||
|
||||
scope "/", RealEstateWeb do
|
||||
|
|
|
@ -2,8 +2,19 @@ defmodule RealEstateWeb.PageLiveTest do
|
|||
use RealEstateWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import RealEstate.AccountsFixtures
|
||||
|
||||
test "disconnected and connected render without authentication should redirect to login page",
|
||||
%{conn: conn} do
|
||||
# If we don't previously log in we will be redirected to the login page
|
||||
assert {:error, {:redirect, %{to: "/users/log_in"}}} = live(conn, "/")
|
||||
end
|
||||
|
||||
test "disconnected and connected render with authentication should redirect to index page", %{
|
||||
conn: conn
|
||||
} do
|
||||
conn = conn |> log_in_user(user_fixture())
|
||||
|
||||
test "disconnected and connected render", %{conn: conn} do
|
||||
{:ok, page_live, disconnected_html} = live(conn, "/")
|
||||
assert disconnected_html =~ "Welcome to Phoenix!"
|
||||
assert render(page_live) =~ "Welcome to Phoenix!"
|
||||
|
|
Loading…
Reference in a new issue