fix tests
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -6,9 +6,30 @@ defmodule Cannery.AmmoTest do | ||||
|   describe "ammo_types" do | ||||
|     alias Cannery.Ammo.AmmoType | ||||
|  | ||||
|     @valid_attrs %{bullet_type: "some bullet_type", case_material: "some case_material", desc: "some desc", manufacturer: "some manufacturer", name: "some name", weight: 120.5} | ||||
|     @update_attrs %{bullet_type: "some updated bullet_type", case_material: "some updated case_material", desc: "some updated desc", manufacturer: "some updated manufacturer", name: "some updated name", weight: 456.7} | ||||
|     @invalid_attrs %{bullet_type: nil, case_material: nil, desc: nil, manufacturer: nil, name: nil, weight: nil} | ||||
|     @valid_attrs %{ | ||||
|       "bullet_type" => "some bullet_type", | ||||
|       "case_material" => "some case_material", | ||||
|       "desc" => "some desc", | ||||
|       "manufacturer" => "some manufacturer", | ||||
|       "name" => "some name", | ||||
|       "weight" => 120.5 | ||||
|     } | ||||
|     @update_attrs %{ | ||||
|       "bullet_type" => "some updated bullet_type", | ||||
|       "case_material" => "some updated case_material", | ||||
|       "desc" => "some updated desc", | ||||
|       "manufacturer" => "some updated manufacturer", | ||||
|       "name" => "some updated name", | ||||
|       "weight" => 456.7 | ||||
|     } | ||||
|     @invalid_attrs %{ | ||||
|       "bullet_type" => nil, | ||||
|       "case_material" => nil, | ||||
|       "desc" => nil, | ||||
|       "manufacturer" => nil, | ||||
|       "name" => nil, | ||||
|       "weight" => nil | ||||
|     } | ||||
|  | ||||
|     def ammo_type_fixture(attrs \\ %{}) do | ||||
|       {:ok, ammo_type} = | ||||
|   | ||||
| @@ -6,8 +6,18 @@ defmodule Cannery.ContainersTest do | ||||
|   describe "containers" do | ||||
|     alias Cannery.Containers.Container | ||||
|  | ||||
|     @valid_attrs %{desc: "some desc", location: "some location", name: "some name", type: "some type"} | ||||
|     @update_attrs %{desc: "some updated desc", location: "some updated location", name: "some updated name", type: "some updated type"} | ||||
|     @valid_attrs %{ | ||||
|       "desc" => "some desc", | ||||
|       "location" => "some location", | ||||
|       "name" => "some name", | ||||
|       "type" => "some type" | ||||
|     } | ||||
|     @update_attrs %{ | ||||
|       "desc" => "some updated desc", | ||||
|       "location" => "some updated location", | ||||
|       "name" => "some updated name", | ||||
|       "type" => "some updated type" | ||||
|     } | ||||
|     @invalid_attrs %{desc: nil, location: nil, name: nil, type: nil} | ||||
|  | ||||
|     def container_fixture(attrs \\ %{}) do | ||||
| @@ -43,7 +53,10 @@ defmodule Cannery.ContainersTest do | ||||
|  | ||||
|     test "update_container/2 with valid data updates the container" do | ||||
|       container = container_fixture() | ||||
|       assert {:ok, %Container{} = container} = Containers.update_container(container, @update_attrs) | ||||
|  | ||||
|       assert {:ok, %Container{} = container} = | ||||
|                Containers.update_container(container, @update_attrs) | ||||
|  | ||||
|       assert container.desc == "some updated desc" | ||||
|       assert container.location == "some updated location" | ||||
|       assert container.name == "some updated name" | ||||
|   | ||||
| @@ -1,20 +1,28 @@ | ||||
| defmodule Cannery.InvitesTest do | ||||
|   use Cannery.DataCase | ||||
|  | ||||
|   alias Cannery.Invites | ||||
|   alias Cannery.{AccountsFixtures, Invites} | ||||
|  | ||||
|   describe "invites" do | ||||
|     alias Cannery.Invites.Invite | ||||
|  | ||||
|     @valid_attrs %{name: "some name", token: "some token"} | ||||
|     @update_attrs %{name: "some updated name", token: "some updated token"} | ||||
|     @invalid_attrs %{name: nil, token: nil} | ||||
|     @valid_attrs %{ | ||||
|       "name" => "some name", | ||||
|       "token" => "some token" | ||||
|     } | ||||
|     @update_attrs %{ | ||||
|       "name" => "some updated name", | ||||
|       "token" => "some updated token" | ||||
|     } | ||||
|     @invalid_attrs %{ | ||||
|       "name" => nil, | ||||
|       "token" => nil | ||||
|     } | ||||
|  | ||||
|     def invite_fixture(attrs \\ %{}) do | ||||
|       {:ok, invite} = | ||||
|         attrs | ||||
|         |> Enum.into(@valid_attrs) | ||||
|         |> Invites.create_invite() | ||||
|         AccountsFixtures.user_fixture() | ||||
|         |> Invites.create_invite(attrs |> Enum.into(@valid_attrs)) | ||||
|  | ||||
|       invite | ||||
|     end | ||||
|   | ||||
| @@ -1,18 +1,33 @@ | ||||
| defmodule Cannery.TagsTest do | ||||
|   use Cannery.DataCase | ||||
|  | ||||
|   alias Cannery.Tags | ||||
|   alias Cannery.{AccountsFixtures, Tags} | ||||
|  | ||||
|   describe "tags" do | ||||
|     alias Cannery.Tags.Tag | ||||
|  | ||||
|     @valid_attrs %{bg_color: "some bg-color", name: "some name", text_color: "some text-color"} | ||||
|     @update_attrs %{bg_color: "some updated bg-color", name: "some updated name", text_color: "some updated text-color"} | ||||
|     @invalid_attrs %{bg_color: nil, name: nil, text_color: nil} | ||||
|     @valid_attrs %{ | ||||
|       "bg_color" => "some bg-color", | ||||
|       "name" => "some name", | ||||
|       "text_color" => "some text-color" | ||||
|     } | ||||
|     @update_attrs %{ | ||||
|       "bg_color" => "some updated bg-color", | ||||
|       "name" => "some updated name", | ||||
|       "text_color" => "some updated text-color" | ||||
|     } | ||||
|     @invalid_attrs %{ | ||||
|       "bg_color" => nil, | ||||
|       "name" => nil, | ||||
|       "text_color" => nil | ||||
|     } | ||||
|  | ||||
|     def tag_fixture(attrs \\ %{}) do | ||||
|       %{id: user_id} = AccountsFixtures.user_fixture() | ||||
|  | ||||
|       {:ok, tag} = | ||||
|         attrs | ||||
|         |> Map.put("user_id", user_id) | ||||
|         |> Enum.into(@valid_attrs) | ||||
|         |> Tags.create_tag() | ||||
|  | ||||
| @@ -31,9 +46,9 @@ defmodule Cannery.TagsTest do | ||||
|  | ||||
|     test "create_tag/1 with valid data creates a tag" do | ||||
|       assert {:ok, %Tag{} = tag} = Tags.create_tag(@valid_attrs) | ||||
|       assert tag.bg-color == "some bg-color" | ||||
|       assert tag.bg_color == "some bg-color" | ||||
|       assert tag.name == "some name" | ||||
|       assert tag.text-color == "some text-color" | ||||
|       assert tag.text_color == "some text-color" | ||||
|     end | ||||
|  | ||||
|     test "create_tag/1 with invalid data returns error changeset" do | ||||
| @@ -43,9 +58,9 @@ defmodule Cannery.TagsTest do | ||||
|     test "update_tag/2 with valid data updates the tag" do | ||||
|       tag = tag_fixture() | ||||
|       assert {:ok, %Tag{} = tag} = Tags.update_tag(tag, @update_attrs) | ||||
|       assert tag.bg-color == "some updated bg-color" | ||||
|       assert tag.bg_color == "some updated bg-color" | ||||
|       assert tag.name == "some updated name" | ||||
|       assert tag.text-color == "some updated text-color" | ||||
|       assert tag.text_color == "some updated text-color" | ||||
|     end | ||||
|  | ||||
|     test "update_tag/2 with invalid data returns error changeset" do | ||||
|   | ||||
| @@ -5,9 +5,30 @@ defmodule CanneryWeb.AmmoTypeLiveTest do | ||||
|  | ||||
|   alias Cannery.Ammo | ||||
|  | ||||
|   @create_attrs %{bullet_type: "some bullet_type", case_material: "some case_material", desc: "some desc", manufacturer: "some manufacturer", name: "some name", weight: 120.5} | ||||
|   @update_attrs %{bullet_type: "some updated bullet_type", case_material: "some updated case_material", desc: "some updated desc", manufacturer: "some updated manufacturer", name: "some updated name", weight: 456.7} | ||||
|   @invalid_attrs %{bullet_type: nil, case_material: nil, desc: nil, manufacturer: nil, name: nil, weight: nil} | ||||
|   @create_attrs %{ | ||||
|     "bullet_type" => "some bullet_type", | ||||
|     "case_material" => "some case_material", | ||||
|     "desc" => "some desc", | ||||
|     "manufacturer" => "some manufacturer", | ||||
|     "name" => "some name", | ||||
|     "weight" => 120.5 | ||||
|   } | ||||
|   @update_attrs %{ | ||||
|     "bullet_type" => "some updated bullet_type", | ||||
|     "case_material" => "some updated case_material", | ||||
|     "desc" => "some updated desc", | ||||
|     "manufacturer" => "some updated manufacturer", | ||||
|     "name" => "some updated name", | ||||
|     "weight" => 456.7 | ||||
|   } | ||||
|   @invalid_attrs %{ | ||||
|     "bullet_type" => nil, | ||||
|     "case_material" => nil, | ||||
|     "desc" => nil, | ||||
|     "manufacturer" => nil, | ||||
|     "name" => nil, | ||||
|     "weight" => nil | ||||
|   } | ||||
|  | ||||
|   defp fixture(:ammo_type) do | ||||
|     {:ok, ammo_type} = Ammo.create_ammo_type(@create_attrs) | ||||
|   | ||||
| @@ -5,8 +5,18 @@ defmodule CanneryWeb.ContainerLiveTest do | ||||
|  | ||||
|   alias Cannery.Containers | ||||
|  | ||||
|   @create_attrs %{desc: "some desc", location: "some location", name: "some name", type: "some type"} | ||||
|   @update_attrs %{desc: "some updated desc", location: "some updated location", name: "some updated name", type: "some updated type"} | ||||
|   @create_attrs %{ | ||||
|     "desc" => "some desc", | ||||
|     "location" => "some location", | ||||
|     "name" => "some name", | ||||
|     "type" => "some type" | ||||
|   } | ||||
|   @update_attrs %{ | ||||
|     "desc" => "some updated desc", | ||||
|     "location" => "some updated location", | ||||
|     "name" => "some updated name", | ||||
|     "type" => "some updated type" | ||||
|   } | ||||
|   @invalid_attrs %{desc: nil, location: nil, name: nil, type: nil} | ||||
|  | ||||
|   defp fixture(:container) do | ||||
|   | ||||
| @@ -5,9 +5,21 @@ defmodule CanneryWeb.TagLiveTest do | ||||
|  | ||||
|   alias Cannery.Tags | ||||
|  | ||||
|   @create_attrs %{bg_color: "some bg-color", name: "some name", text_color: "some text-color"} | ||||
|   @update_attrs %{bg_color: "some updated bg-color", name: "some updated name", text_color: "some updated text-color"} | ||||
|   @invalid_attrs %{bg_color: nil, name: nil, text_color: nil} | ||||
|   @create_attrs %{ | ||||
|     "bg_color" => "some bg-color", | ||||
|     "name" => "some name", | ||||
|     "text_color" => "some text-color" | ||||
|   } | ||||
|   @update_attrs %{ | ||||
|     "bg_color" => "some updated bg-color", | ||||
|     "name" => "some updated name", | ||||
|     "text_color" => "some updated text-color" | ||||
|   } | ||||
|   @invalid_attrs %{ | ||||
|     "bg_color" => nil, | ||||
|     "name" => nil, | ||||
|     "text_color" => nil | ||||
|   } | ||||
|  | ||||
|   defp fixture(:tag) do | ||||
|     {:ok, tag} = Tags.create_tag(@create_attrs) | ||||
| @@ -26,7 +38,7 @@ defmodule CanneryWeb.TagLiveTest do | ||||
|       {:ok, _index_live, html} = live(conn, Routes.tag_index_path(conn, :index)) | ||||
|  | ||||
|       assert html =~ "Listing Tags" | ||||
|       assert html =~ tag.bg-color | ||||
|       assert html =~ tag.bg_color | ||||
|     end | ||||
|  | ||||
|     test "saves new tag", %{conn: conn} do | ||||
| @@ -88,7 +100,7 @@ defmodule CanneryWeb.TagLiveTest do | ||||
|       {:ok, _show_live, html} = live(conn, Routes.tag_show_path(conn, :show, tag)) | ||||
|  | ||||
|       assert html =~ "Show Tag" | ||||
|       assert html =~ tag.bg-color | ||||
|       assert html =~ tag.bg_color | ||||
|     end | ||||
|  | ||||
|     test "updates tag within modal", %{conn: conn, tag: tag} do | ||||
|   | ||||
| @@ -4,9 +4,13 @@ defmodule Cannery.AccountsFixtures do | ||||
|   entities via the `Cannery.Accounts` context. | ||||
|   """ | ||||
|  | ||||
|   alias Cannery.{Accounts} | ||||
|  | ||||
|   def unique_user_email, do: "user#{System.unique_integer()}@example.com" | ||||
|   def valid_user_password, do: "hello world!" | ||||
|  | ||||
|   @spec user_fixture() :: Accounts.User.t() | ||||
|   @spec user_fixture(attrs :: map()) :: Accounts.User.t() | ||||
|   def user_fixture(attrs \\ %{}) do | ||||
|     {:ok, user} = | ||||
|       attrs | ||||
| @@ -14,7 +18,7 @@ defmodule Cannery.AccountsFixtures do | ||||
|         email: unique_user_email(), | ||||
|         password: valid_user_password() | ||||
|       }) | ||||
|       |> Cannery.Accounts.register_user() | ||||
|       |> Accounts.register_user() | ||||
|  | ||||
|     user | ||||
|   end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user