pass containers test
This commit is contained in:
		| @@ -50,7 +50,7 @@ defmodule Cannery.ActivityLogTest do | |||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "get_shot_group!/1 does not return a shot_group of another user", |     test "get_shot_group!/1 does not return a shot_group of another user", | ||||||
|          %{shot_group: shot_group, current_user: current_user} do |          %{shot_group: shot_group} do | ||||||
|       another_user = user_fixture() |       another_user = user_fixture() | ||||||
|  |  | ||||||
|       assert_raise Ecto.NoResultsError, fn -> |       assert_raise Ecto.NoResultsError, fn -> | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ defmodule Cannery.AmmoTest do | |||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_ammo_type/1 with valid data creates a ammo_type", |     test "create_ammo_type/1 with valid data creates a ammo_type", | ||||||
|          %{ammo_type: ammo_type, current_user: current_user} do |          %{current_user: current_user} do | ||||||
|       assert {:ok, %AmmoType{} = ammo_type} = Ammo.create_ammo_type(@valid_attrs, current_user) |       assert {:ok, %AmmoType{} = ammo_type} = Ammo.create_ammo_type(@valid_attrs, current_user) | ||||||
|       assert ammo_type.bullet_type == "some bullet_type" |       assert ammo_type.bullet_type == "some bullet_type" | ||||||
|       assert ammo_type.case_material == "some case_material" |       assert ammo_type.case_material == "some case_material" | ||||||
| @@ -62,7 +62,7 @@ defmodule Cannery.AmmoTest do | |||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_ammo_type/1 with invalid data returns error changeset", |     test "create_ammo_type/1 with invalid data returns error changeset", | ||||||
|          %{ammo_type: ammo_type, current_user: current_user} do |          %{current_user: current_user} do | ||||||
|       assert {:error, %Changeset{}} = Ammo.create_ammo_type(@invalid_attrs, current_user) |       assert {:error, %Changeset{}} = Ammo.create_ammo_type(@invalid_attrs, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
| @@ -131,7 +131,6 @@ defmodule Cannery.AmmoTest do | |||||||
|     test "create_ammo_group/1 with valid data creates a ammo_group", |     test "create_ammo_group/1 with valid data creates a ammo_group", | ||||||
|          %{ |          %{ | ||||||
|            ammo_type: ammo_type, |            ammo_type: ammo_type, | ||||||
|            ammo_group: ammo_group, |  | ||||||
|            container: container, |            container: container, | ||||||
|            current_user: current_user |            current_user: current_user | ||||||
|          } do |          } do | ||||||
|   | |||||||
| @@ -9,62 +9,60 @@ defmodule Cannery.ContainersTest do | |||||||
|   alias Cannery.{Accounts.User, Containers.Container} |   alias Cannery.{Accounts.User, Containers.Container} | ||||||
|   alias Ecto.Changeset |   alias Ecto.Changeset | ||||||
|  |  | ||||||
|   @moduletag :containers |   @moduletag :containers_test | ||||||
|  |  | ||||||
|  |   @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} | ||||||
|  |  | ||||||
|   describe "containers" do |   describe "containers" do | ||||||
|     @valid_attrs %{ |     setup do | ||||||
|       "desc" => "some desc", |       current_user = user_fixture() | ||||||
|       "location" => "some location", |       container = container_fixture(current_user) | ||||||
|       "name" => "some name", |       [current_user: current_user, container: container] | ||||||
|       "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} |  | ||||||
|  |  | ||||||
|     @spec container_fixture(User.t(), map()) :: Container.t() |  | ||||||
|     def container_fixture(user, attrs \\ %{}) do |  | ||||||
|       {:ok, container} = @valid_attrs |> Map.merge(attrs) |> Containers.create_container(user) |  | ||||||
|  |  | ||||||
|       container |  | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "list_containers/1 returns all containers" do |     test "list_containers/1 returns all containers", | ||||||
|       user = user_fixture() |          %{current_user: current_user, container: container} do | ||||||
|       container = user |> container_fixture() |       assert Containers.list_containers(current_user) == [container] | ||||||
|       assert Containers.list_containers(user) == [container] |  | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "get_container!/1 returns the container with given id" do |     test "get_container!/1 returns the container with given id", | ||||||
|       container = user_fixture() |> container_fixture() |          %{current_user: current_user, container: container} do | ||||||
|       assert Containers.get_container!(container.id) == container |       assert Containers.get_container!(container.id, current_user) == container | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_container/1 with valid data creates a container" do |     test "create_container/1 with valid data creates a container", | ||||||
|       user = user_fixture() |          %{current_user: current_user, container: container} do | ||||||
|       assert {:ok, %Container{} = container} = @valid_attrs |> Containers.create_container(user) |       assert {:ok, %Container{} = container} = | ||||||
|  |                @valid_attrs |> Containers.create_container(current_user) | ||||||
|  |  | ||||||
|       assert container.desc == "some desc" |       assert container.desc == "some desc" | ||||||
|       assert container.location == "some location" |       assert container.location == "some location" | ||||||
|       assert container.name == "some name" |       assert container.name == "some name" | ||||||
|       assert container.type == "some type" |       assert container.type == "some type" | ||||||
|       assert container.user_id == user.id |       assert container.user_id == current_user.id | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_container/1 with invalid data returns error changeset" do |     test "create_container/1 with invalid data returns error changeset", | ||||||
|       assert {:error, %Changeset{}} = |          %{current_user: current_user} do | ||||||
|                @invalid_attrs |> Containers.create_container(user_fixture()) |       assert {:error, %Changeset{}} = @invalid_attrs |> Containers.create_container(current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "update_container/2 with valid data updates the container" do |     test "update_container/2 with valid data updates the container", | ||||||
|       user = user_fixture() |          %{current_user: current_user, container: container} do | ||||||
|       container = user |> container_fixture() |  | ||||||
|  |  | ||||||
|       assert {:ok, %Container{} = container} = |       assert {:ok, %Container{} = container} = | ||||||
|                Containers.update_container(container, user, @update_attrs) |                Containers.update_container(container, current_user, @update_attrs) | ||||||
|  |  | ||||||
|       assert container.desc == "some updated desc" |       assert container.desc == "some updated desc" | ||||||
|       assert container.location == "some updated location" |       assert container.location == "some updated location" | ||||||
| @@ -72,22 +70,24 @@ defmodule Cannery.ContainersTest do | |||||||
|       assert container.type == "some updated type" |       assert container.type == "some updated type" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "update_container/2 with invalid data returns error changeset" do |     test "update_container/2 with invalid data returns error changeset", | ||||||
|       user = user_fixture() |          %{current_user: current_user, container: container} do | ||||||
|       container = user |> container_fixture() |       assert {:error, %Changeset{}} = | ||||||
|       assert {:error, %Changeset{}} = Containers.update_container(container, user, @invalid_attrs) |                Containers.update_container(container, current_user, @invalid_attrs) | ||||||
|       assert container == Containers.get_container!(container.id) |  | ||||||
|  |       assert container == Containers.get_container!(container.id, current_user) | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "delete_container/1 deletes the container" do |     test "delete_container/1 deletes the container", | ||||||
|       user = user_fixture() |          %{current_user: current_user, container: container} do | ||||||
|       container = user |> container_fixture() |       assert {:ok, %Container{}} = Containers.delete_container(container, current_user) | ||||||
|       assert {:ok, %Container{}} = Containers.delete_container(container, user) |  | ||||||
|       assert_raise Ecto.NoResultsError, fn -> Containers.get_container!(container.id) end |       assert_raise Ecto.NoResultsError, fn -> | ||||||
|  |         Containers.get_container!(container.id, current_user) | ||||||
|  |       end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "change_container/1 returns a container changeset" do |     test "change_container/1 returns a container changeset", %{container: container} do | ||||||
|       container = user_fixture() |> container_fixture() |  | ||||||
|       assert %Changeset{} = Containers.change_container(container) |       assert %Changeset{} = Containers.change_container(container) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ defmodule Cannery.TagsTest do | |||||||
|       assert Tags.get_tag!(tag.id, current_user) == tag |       assert Tags.get_tag!(tag.id, current_user) == tag | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     test "create_tag/1 with valid data creates a tag", %{tag: tag, current_user: current_user} do |     test "create_tag/1 with valid data creates a tag", %{current_user: current_user} do | ||||||
|       assert {:ok, %Tag{} = tag} = Tags.create_tag(@valid_attrs, current_user) |       assert {:ok, %Tag{} = tag} = Tags.create_tag(@valid_attrs, current_user) | ||||||
|       assert tag.bg_color == "some bg-color" |       assert tag.bg_color == "some bg-color" | ||||||
|       assert tag.name == "some name" |       assert tag.name == "some name" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user