forked from shibao/cannery
rename ammo_type type to class
This commit is contained in:
@ -343,21 +343,21 @@ defmodule Cannery.ActivityLogTest do
|
||||
other_user = user_fixture()
|
||||
other_container = container_fixture(other_user)
|
||||
|
||||
for type <- ["rifle", "shotgun", "pistol"] do
|
||||
other_ammo_type = ammo_type_fixture(%{type: type}, other_user)
|
||||
for class <- ["rifle", "shotgun", "pistol"] do
|
||||
other_ammo_type = ammo_type_fixture(%{class: class}, other_user)
|
||||
{1, [other_ammo_group]} = ammo_group_fixture(other_ammo_type, other_container, other_user)
|
||||
shot_group_fixture(other_user, other_ammo_group)
|
||||
end
|
||||
|
||||
rifle_ammo_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
{1, [rifle_ammo_group]} = ammo_group_fixture(rifle_ammo_type, container, current_user)
|
||||
rifle_shot_group = shot_group_fixture(current_user, rifle_ammo_group)
|
||||
|
||||
shotgun_ammo_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
{1, [shotgun_ammo_group]} = ammo_group_fixture(shotgun_ammo_type, container, current_user)
|
||||
shotgun_shot_group = shot_group_fixture(current_user, shotgun_ammo_group)
|
||||
|
||||
pistol_ammo_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
{1, [pistol_ammo_group]} = ammo_group_fixture(pistol_ammo_type, container, current_user)
|
||||
pistol_shot_group = shot_group_fixture(current_user, pistol_ammo_group)
|
||||
|
||||
|
@ -41,7 +41,7 @@ defmodule Cannery.AmmoTest do
|
||||
rifle_ammo_type =
|
||||
%{
|
||||
name: "bullets",
|
||||
type: "rifle",
|
||||
class: :rifle,
|
||||
desc: "has some pews in it",
|
||||
grains: 5
|
||||
}
|
||||
@ -50,14 +50,14 @@ defmodule Cannery.AmmoTest do
|
||||
shotgun_ammo_type =
|
||||
%{
|
||||
name: "hollows",
|
||||
type: "shotgun",
|
||||
class: :shotgun,
|
||||
grains: 3
|
||||
}
|
||||
|> ammo_type_fixture(current_user)
|
||||
|
||||
pistol_ammo_type =
|
||||
%{
|
||||
type: "pistol",
|
||||
class: :pistol,
|
||||
name: "jackets",
|
||||
desc: "brass shell",
|
||||
tracer: true
|
||||
@ -750,11 +750,11 @@ defmodule Cannery.AmmoTest do
|
||||
current_user = user_fixture()
|
||||
container = container_fixture(current_user)
|
||||
|
||||
rifle_ammo_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
{1, [rifle_ammo_group]} = ammo_group_fixture(rifle_ammo_type, container, current_user)
|
||||
shotgun_ammo_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
{1, [shotgun_ammo_group]} = ammo_group_fixture(shotgun_ammo_type, container, current_user)
|
||||
pistol_ammo_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
{1, [pistol_ammo_group]} = ammo_group_fixture(pistol_ammo_type, container, current_user)
|
||||
|
||||
assert [^rifle_ammo_group] = Ammo.list_ammo_groups(nil, :rifle, current_user, false)
|
||||
@ -858,11 +858,11 @@ defmodule Cannery.AmmoTest do
|
||||
current_user = user_fixture()
|
||||
container = container_fixture(current_user)
|
||||
|
||||
rifle_ammo_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
{1, [rifle_ammo_group]} = ammo_group_fixture(rifle_ammo_type, container, current_user)
|
||||
shotgun_ammo_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
{1, [shotgun_ammo_group]} = ammo_group_fixture(shotgun_ammo_type, container, current_user)
|
||||
pistol_ammo_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
{1, [pistol_ammo_group]} = ammo_group_fixture(pistol_ammo_type, container, current_user)
|
||||
|
||||
another_container = container_fixture(current_user)
|
||||
|
@ -64,11 +64,11 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
||||
|
||||
test "can sort by type",
|
||||
%{conn: conn, container: container, current_user: current_user} do
|
||||
rifle_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
rifle_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
{1, [rifle_ammo_group]} = ammo_group_fixture(rifle_type, container, current_user)
|
||||
shotgun_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
shotgun_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
{1, [shotgun_ammo_group]} = ammo_group_fixture(shotgun_type, container, current_user)
|
||||
pistol_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
pistol_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
{1, [pistol_ammo_group]} = ammo_group_fixture(pistol_type, container, current_user)
|
||||
|
||||
{:ok, index_live, html} = live(conn, Routes.ammo_group_index_path(conn, :index))
|
||||
@ -81,8 +81,8 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :rifle})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :rifle})
|
||||
|
||||
assert html =~ rifle_ammo_group.ammo_type.name
|
||||
refute html =~ shotgun_ammo_group.ammo_type.name
|
||||
@ -90,8 +90,8 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :shotgun})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :shotgun})
|
||||
|
||||
refute html =~ rifle_ammo_group.ammo_type.name
|
||||
assert html =~ shotgun_ammo_group.ammo_type.name
|
||||
@ -99,8 +99,8 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :pistol})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :pistol})
|
||||
|
||||
refute html =~ rifle_ammo_group.ammo_type.name
|
||||
refute html =~ shotgun_ammo_group.ammo_type.name
|
||||
@ -108,8 +108,8 @@ defmodule CanneryWeb.AmmoGroupLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :all})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :all})
|
||||
|
||||
assert html =~ rifle_ammo_group.ammo_type.name
|
||||
assert html =~ shotgun_ammo_group.ammo_type.name
|
||||
|
@ -69,10 +69,10 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
assert html =~ ammo_type.bullet_type
|
||||
end
|
||||
|
||||
test "can sort by type", %{conn: conn, current_user: current_user} do
|
||||
rifle_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
shotgun_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
pistol_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
test "can sort by class", %{conn: conn, current_user: current_user} do
|
||||
rifle_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
shotgun_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
pistol_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
|
||||
{:ok, index_live, html} = live(conn, Routes.ammo_type_index_path(conn, :index))
|
||||
|
||||
@ -84,8 +84,8 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :rifle})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :rifle})
|
||||
|
||||
assert html =~ rifle_type.name
|
||||
refute html =~ shotgun_type.name
|
||||
@ -93,8 +93,8 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :shotgun})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :shotgun})
|
||||
|
||||
refute html =~ rifle_type.name
|
||||
assert html =~ shotgun_type.name
|
||||
@ -102,8 +102,8 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :pistol})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :pistol})
|
||||
|
||||
refute html =~ rifle_type.name
|
||||
refute html =~ shotgun_type.name
|
||||
@ -111,8 +111,8 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :all})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :all})
|
||||
|
||||
assert html =~ rifle_type.name
|
||||
assert html =~ shotgun_type.name
|
||||
|
@ -245,11 +245,11 @@ defmodule CanneryWeb.ContainerLiveTest do
|
||||
|
||||
test "can sort by type",
|
||||
%{conn: conn, container: container, current_user: current_user} do
|
||||
rifle_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
rifle_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
{1, [rifle_ammo_group]} = ammo_group_fixture(rifle_type, container, current_user)
|
||||
shotgun_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
shotgun_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
{1, [shotgun_ammo_group]} = ammo_group_fixture(shotgun_type, container, current_user)
|
||||
pistol_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
pistol_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
{1, [pistol_ammo_group]} = ammo_group_fixture(pistol_type, container, current_user)
|
||||
|
||||
{:ok, index_live, html} = live(conn, Routes.container_show_path(conn, :show, container))
|
||||
@ -262,8 +262,8 @@ defmodule CanneryWeb.ContainerLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :rifle})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :rifle})
|
||||
|
||||
assert html =~ rifle_ammo_group.ammo_type.name
|
||||
refute html =~ shotgun_ammo_group.ammo_type.name
|
||||
@ -271,8 +271,8 @@ defmodule CanneryWeb.ContainerLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :shotgun})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :shotgun})
|
||||
|
||||
refute html =~ rifle_ammo_group.ammo_type.name
|
||||
assert html =~ shotgun_ammo_group.ammo_type.name
|
||||
@ -280,8 +280,8 @@ defmodule CanneryWeb.ContainerLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :pistol})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :pistol})
|
||||
|
||||
refute html =~ rifle_ammo_group.ammo_type.name
|
||||
refute html =~ shotgun_ammo_group.ammo_type.name
|
||||
@ -289,8 +289,8 @@ defmodule CanneryWeb.ContainerLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :all})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :all})
|
||||
|
||||
assert html =~ rifle_ammo_group.ammo_type.name
|
||||
assert html =~ shotgun_ammo_group.ammo_type.name
|
||||
|
@ -42,18 +42,18 @@ defmodule CanneryWeb.RangeLiveTest do
|
||||
|
||||
test "can sort by type",
|
||||
%{conn: conn, container: container, current_user: current_user} do
|
||||
rifle_ammo_type = ammo_type_fixture(%{type: "rifle"}, current_user)
|
||||
rifle_ammo_type = ammo_type_fixture(%{class: :rifle}, current_user)
|
||||
{1, [rifle_ammo_group]} = ammo_group_fixture(rifle_ammo_type, container, current_user)
|
||||
|
||||
rifle_shot_group = shot_group_fixture(%{notes: "group_one"}, current_user, rifle_ammo_group)
|
||||
|
||||
shotgun_ammo_type = ammo_type_fixture(%{type: "shotgun"}, current_user)
|
||||
shotgun_ammo_type = ammo_type_fixture(%{class: :shotgun}, current_user)
|
||||
{1, [shotgun_ammo_group]} = ammo_group_fixture(shotgun_ammo_type, container, current_user)
|
||||
|
||||
shotgun_shot_group =
|
||||
shot_group_fixture(%{notes: "group_two"}, current_user, shotgun_ammo_group)
|
||||
|
||||
pistol_ammo_type = ammo_type_fixture(%{type: "pistol"}, current_user)
|
||||
pistol_ammo_type = ammo_type_fixture(%{class: :pistol}, current_user)
|
||||
{1, [pistol_ammo_group]} = ammo_group_fixture(pistol_ammo_type, container, current_user)
|
||||
|
||||
pistol_shot_group =
|
||||
@ -69,8 +69,8 @@ defmodule CanneryWeb.RangeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :rifle})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :rifle})
|
||||
|
||||
assert html =~ rifle_shot_group.notes
|
||||
refute html =~ shotgun_shot_group.notes
|
||||
@ -78,8 +78,8 @@ defmodule CanneryWeb.RangeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :shotgun})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :shotgun})
|
||||
|
||||
refute html =~ rifle_shot_group.notes
|
||||
assert html =~ shotgun_shot_group.notes
|
||||
@ -87,8 +87,8 @@ defmodule CanneryWeb.RangeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :pistol})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :pistol})
|
||||
|
||||
refute html =~ rifle_shot_group.notes
|
||||
refute html =~ shotgun_shot_group.notes
|
||||
@ -96,8 +96,8 @@ defmodule CanneryWeb.RangeLiveTest do
|
||||
|
||||
html =
|
||||
index_live
|
||||
|> form(~s/form[phx-change="change_type"]/)
|
||||
|> render_change(ammo_type: %{type: :all})
|
||||
|> form(~s/form[phx-change="change_class"]/)
|
||||
|> render_change(ammo_type: %{class: :all})
|
||||
|
||||
assert html =~ rifle_shot_group.notes
|
||||
assert html =~ shotgun_shot_group.notes
|
||||
|
@ -103,7 +103,7 @@ defmodule Cannery.Fixtures do
|
||||
@spec ammo_type_fixture(attrs :: map(), User.t()) :: AmmoType.t()
|
||||
def ammo_type_fixture(attrs \\ %{}, %User{} = user) do
|
||||
attrs
|
||||
|> Enum.into(%{name: random_string(), type: "rifle"})
|
||||
|> Enum.into(%{name: random_string(), class: :rifle})
|
||||
|> Ammo.create_ammo_type(user)
|
||||
|> unwrap_ok_tuple()
|
||||
end
|
||||
|
Reference in New Issue
Block a user