diff --git a/lib/pokemon_couture_web/controllers/clothes_controller.ex b/lib/pokemon_couture_web/controllers/clothes_controller.ex index 0fc9edb..5f9930a 100644 --- a/lib/pokemon_couture_web/controllers/clothes_controller.ex +++ b/lib/pokemon_couture_web/controllers/clothes_controller.ex @@ -17,7 +17,6 @@ defmodule PokemonCoutureWeb.ClothesController do clothes_map = clothes |> Enum.reduce(%{}, &create_shop_map/2) - # IO.inspect(clothes_map) render(conn, "index.html", clothes: clothes, clothes_map: clothes_map) end diff --git a/test/pokemon_couture/shops_test.exs b/test/pokemon_couture/shops_test.exs index 31535a9..0dc8380 100644 --- a/test/pokemon_couture/shops_test.exs +++ b/test/pokemon_couture/shops_test.exs @@ -3,6 +3,7 @@ defmodule PokemonCouture.ShopsTest do alias PokemonCouture.Shops + import PokemonCouture.AccountsFixtures describe "clothes" do alias PokemonCouture.Shops.Clothes @@ -23,6 +24,11 @@ defmodule PokemonCouture.ShopsTest do assert length(Shops.list_clothes()) > 0 end + test "valid piece of clothing in list_clothes/0" do + clothes = Shops.get_clothes!(1) + assert clothes in Shops.list_clothes() + end + test "get_clothes!/1 returns the clothes with given id" do clothes = clothes_fixture() assert Shops.get_clothes!(clothes.id) == clothes @@ -63,5 +69,20 @@ defmodule PokemonCouture.ShopsTest do clothes = clothes_fixture() assert %Ecto.Changeset{} = Shops.change_clothes(clothes) end + + test "check if list clothes with owners has owners" do + clothes_with_owners = Shops.list_clothes_with_owners() + clothes_piece = hd(clothes_with_owners) + assert clothes_piece.users + end + + test "clothes owner adding and removing test" do + clothes_piece = hd(Shops.list_clothes_with_owners()) + user = user_fixture() + clothes_piece = Shops.add_owner(clothes_piece, user) + assert user in clothes_piece.users + clothes_piece = Shops.remove_owner(clothes_piece, user) + assert user not in clothes_piece.users + end end end