From 8d9da4ea40c2bb1efafc6b95f06bfc1b8cc542e1 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Balsini Moura Date: Mon, 14 Sep 2020 13:52:17 -0300 Subject: [PATCH] Fix properties tests by logging user in --- .../real_estate_web/live/property_live_test.exs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/real_estate_web/live/property_live_test.exs b/test/real_estate_web/live/property_live_test.exs index 928e23f..4ed2679 100644 --- a/test/real_estate_web/live/property_live_test.exs +++ b/test/real_estate_web/live/property_live_test.exs @@ -2,11 +2,16 @@ defmodule RealEstateWeb.PropertyLiveTest do use RealEstateWeb.ConnCase import Phoenix.LiveViewTest + import RealEstate.AccountsFixtures alias RealEstate.Properties @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} defp fixture(:property) do @@ -22,6 +27,11 @@ defmodule RealEstateWeb.PropertyLiveTest do describe "Index" do 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 {:ok, _index_live, html} = live(conn, Routes.property_index_path(conn, :index)) @@ -84,6 +94,11 @@ defmodule RealEstateWeb.PropertyLiveTest do describe "Show" do 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 {:ok, _show_live, html} = live(conn, Routes.property_show_path(conn, :show, property))