Fix properties tests by logging user in

This commit is contained in:
Joao Gilberto Balsini Moura 2020-09-14 13:52:17 -03:00
parent 8e548cfa5a
commit 8d9da4ea40

View file

@ -2,11 +2,16 @@ defmodule RealEstateWeb.PropertyLiveTest do
use RealEstateWeb.ConnCase use RealEstateWeb.ConnCase
import Phoenix.LiveViewTest import Phoenix.LiveViewTest
import RealEstate.AccountsFixtures
alias RealEstate.Properties alias RealEstate.Properties
@create_attrs %{description: "some description", name: "some name", price: "120.5"} @create_attrs %{description: "some description", name: "some name", price: "120.5"}
@update_attrs %{description: "some updated description", name: "some updated name", price: "456.7"} @update_attrs %{
description: "some updated description",
name: "some updated name",
price: "456.7"
}
@invalid_attrs %{description: nil, name: nil, price: nil} @invalid_attrs %{description: nil, name: nil, price: nil}
defp fixture(:property) do defp fixture(:property) do
@ -22,6 +27,11 @@ defmodule RealEstateWeb.PropertyLiveTest do
describe "Index" do describe "Index" do
setup [:create_property] setup [:create_property]
setup %{conn: conn} do
conn = log_in_user(conn, user_fixture())
%{conn: conn}
end
test "lists all properties", %{conn: conn, property: property} do test "lists all properties", %{conn: conn, property: property} do
{:ok, _index_live, html} = live(conn, Routes.property_index_path(conn, :index)) {:ok, _index_live, html} = live(conn, Routes.property_index_path(conn, :index))
@ -84,6 +94,11 @@ defmodule RealEstateWeb.PropertyLiveTest do
describe "Show" do describe "Show" do
setup [:create_property] setup [:create_property]
setup %{conn: conn} do
conn = log_in_user(conn, user_fixture())
%{conn: conn}
end
test "displays property", %{conn: conn, property: property} do test "displays property", %{conn: conn, property: property} do
{:ok, _show_live, html} = live(conn, Routes.property_show_path(conn, :show, property)) {:ok, _show_live, html} = live(conn, Routes.property_show_path(conn, :show, property))