rename ammo groups to packs everywhere

This commit is contained in:
2023-03-29 23:49:45 -04:00
parent 0544b58ab6
commit 4b6d0952f8
35 changed files with 160 additions and 168 deletions

View File

@ -59,7 +59,7 @@ defmodule Cannery.ActivityLogTest do
assert shot_group.notes == "some notes"
end
test "create_shot_group/3 removes corresponding count from ammo group",
test "create_shot_group/3 removes corresponding count from pack",
%{
current_user: current_user,
pack: %{id: pack_id, count: org_count} = pack
@ -75,7 +75,7 @@ defmodule Cannery.ActivityLogTest do
assert new_count == 10
end
test "create_shot_group/3 does not remove more than ammo group amount",
test "create_shot_group/3 does not remove more tha pack amount",
%{current_user: current_user, pack: %{id: pack_id} = pack} do
valid_attrs = %{count: 20, date: ~D[2022-02-13], notes: "some notes"}
@ -302,7 +302,7 @@ defmodule Cannery.ActivityLogTest do
[ammo_type, another_ammo_type]
|> ActivityLog.get_used_count_for_ammo_types(current_user)
# use generated ammo group
# use generated pack
shot_group_fixture(%{count: 5}, current_user, pack)
used_counts =
@ -311,7 +311,7 @@ defmodule Cannery.ActivityLogTest do
assert %{^ammo_type_id => 5} = used_counts
assert %{^another_ammo_type_id => 5} = used_counts
# use generated ammo group again
# use generated pack again
shot_group_fixture(%{count: 1}, current_user, pack)
used_counts =
@ -407,7 +407,7 @@ defmodule Cannery.ActivityLogTest do
# notes
assert ActivityLog.list_shot_groups("amazing", :all, current_user) == [shot_group_a]
# ammo group attributes
# pack attributes
assert ActivityLog.list_shot_groups("stupendous", :all, current_user) == [shot_group_b]
# ammo type attributes

View File

@ -4,7 +4,7 @@ defmodule Cannery.AmmoTest do
"""
use Cannery.DataCase
alias Cannery.{Ammo, Ammo.Pack, Ammo.AmmoType, Containers}
alias Cannery.{Ammo, Ammo.AmmoType, Ammo.Pack, Containers}
alias Ecto.Changeset
@moduletag :ammo_test
@ -211,7 +211,7 @@ defmodule Cannery.AmmoTest do
end
end
describe "ammo types with ammo groups" do
describe "ammo types with packs" do
setup do
current_user = user_fixture()
ammo_type = ammo_type_fixture(current_user)
@ -516,14 +516,14 @@ defmodule Cannery.AmmoTest do
[ammo_type, another_ammo_type]
|> Ammo.get_used_packs_count_for_types(current_user)
# testing ammo type with ammo group
# testing ammo type with pack
{1, [first_pack]} = pack_fixture(%{count: 1}, ammo_type, container, current_user)
assert %{} ==
[ammo_type, another_ammo_type]
|> Ammo.get_used_packs_count_for_types(current_user)
# testing ammo type with used ammo group
# testing ammo type with used pack
{1, [another_pack]} = pack_fixture(%{count: 50}, another_ammo_type, container, current_user)
shot_group_fixture(%{count: 50}, current_user, another_pack)
@ -532,7 +532,7 @@ defmodule Cannery.AmmoTest do
[ammo_type, another_ammo_type]
|> Ammo.get_used_packs_count_for_types(current_user)
# testing two ammo types with zero and one used ammo groups
# testing two ammo types with zero and one used packs
{1, [pack]} = pack_fixture(%{count: 50}, ammo_type, container, current_user)
shot_group_fixture(%{count: 50}, current_user, pack)
@ -542,7 +542,7 @@ defmodule Cannery.AmmoTest do
assert %{^ammo_type_id => 1} = used_counts
assert %{^another_ammo_type_id => 1} = used_counts
# testing two ammo type with one and two used ammo groups
# testing two ammo type with one and two used packs
shot_group_fixture(%{count: 1}, current_user, first_pack)
used_counts =
@ -778,14 +778,14 @@ defmodule Cannery.AmmoTest do
assert pack in packs
end
test "list_packs/4 returns relevant ammo groups when searched", %{
test "list_packs/4 returns relevant packs when searched", %{
ammo_type: ammo_type,
pack: pack,
container: container,
current_user: current_user
} do
{1, [another_pack]} =
%{count: 49, notes: "cool ammo group"}
%{count: 49, notes: "cool pack"}
|> pack_fixture(ammo_type, container, current_user)
another_ammo_type = ammo_type_fixture(%{name: "amazing ammo"}, current_user)
@ -806,7 +806,7 @@ defmodule Cannery.AmmoTest do
assert another_pack in packs
assert pack in packs
# search works for ammo group attributes
# search works for pack attributes
assert Ammo.list_packs("cool", :all, current_user, true) == [another_pack]
# search works for ammo type attributes

View File

@ -34,7 +34,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
grains: nil
}
@pack_attrs %{
notes: "some ammo group",
notes: "some pack",
count: 20
}
@shot_group_attrs %{
@ -248,10 +248,10 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
end
end
describe "Index with ammo group" do
describe "Index with pack" do
setup [:register_and_log_in_user, :create_ammo_type, :create_pack]
test "shows used ammo groups on toggle",
test "shows used packs on toggle",
%{conn: conn, pack: pack, current_user: current_user} do
{:ok, index_live, html} = live(conn, Routes.ammo_type_index_path(conn, :index))
@ -327,10 +327,10 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
end
end
describe "Show ammo type with ammo group" do
describe "Show ammo type with pack" do
setup [:register_and_log_in_user, :create_ammo_type, :create_pack]
test "displays ammo group", %{
test "displays pack", %{
conn: conn,
ammo_type: %{name: ammo_type_name} = ammo_type,
container: %{name: container_name}
@ -342,7 +342,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
assert html =~ container_name
end
test "displays ammo group in table",
test "displays pack in table",
%{conn: conn, ammo_type: ammo_type, container: %{name: container_name}} do
{:ok, show_live, _html} = live(conn, Routes.ammo_type_show_path(conn, :show, ammo_type))
@ -356,10 +356,10 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
end
end
describe "Show ammo type with empty ammo group" do
describe "Show ammo type with empty pack" do
setup [:register_and_log_in_user, :create_ammo_type, :create_empty_pack]
test "displays empty ammo groups on toggle",
test "displays empty packs on toggle",
%{conn: conn, ammo_type: ammo_type, container: %{name: container_name}} do
{:ok, show_live, html} = live(conn, Routes.ammo_type_show_path(conn, :show, ammo_type))
assert html =~ "Show used"
@ -375,7 +375,7 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
assert html =~ container_name
end
test "displays empty ammo groups in table on toggle",
test "displays empty packs in table on toggle",
%{conn: conn, ammo_type: ammo_type, container: %{name: container_name}} do
{:ok, show_live, _html} = live(conn, Routes.ammo_type_show_path(conn, :show, ammo_type))

View File

@ -31,7 +31,7 @@ defmodule CanneryWeb.ContainerLiveTest do
grains: 120
}
@pack_attrs %{
notes: "some ammo group",
notes: "some pack",
count: 20
}
@ -298,10 +298,10 @@ defmodule CanneryWeb.ContainerLiveTest do
end
end
describe "Show with ammo group" do
describe "Show with pack" do
setup [:register_and_log_in_user, :create_container, :create_pack]
test "displays ammo group",
test "displays pack",
%{conn: conn, ammo_type: %{name: ammo_type_name}, container: container} do
{:ok, _show_live, html} = live(conn, Routes.container_show_path(conn, :show, container))
@ -309,7 +309,7 @@ defmodule CanneryWeb.ContainerLiveTest do
assert html =~ "\n20\n"
end
test "displays ammo group in table",
test "displays pack in table",
%{conn: conn, ammo_type: %{name: ammo_type_name}, container: container} do
{:ok, show_live, _html} = live(conn, Routes.container_show_path(conn, :show, container))

View File

@ -1,6 +1,6 @@
defmodule CanneryWeb.PackLiveTest do
@moduledoc """
Tests ammo group live pages
Tests pack live pages
"""
use CanneryWeb.ConnCase
@ -52,7 +52,7 @@ defmodule CanneryWeb.PackLiveTest do
[empty_pack: pack, shot_group: shot_group]
end
describe "Index of ammo group" do
describe "Index of pack" do
setup [:register_and_log_in_user, :create_pack]
test "lists all packs", %{conn: conn, pack: pack} do
@ -213,7 +213,7 @@ defmodule CanneryWeb.PackLiveTest do
{:ok, index_live, _html} = live(conn, Routes.pack_index_path(conn, :index))
assert index_live
|> element(~s/a[aria-label="Edit ammo group of #{pack.count} bullets"]/)
|> element(~s/a[aria-label="Edit pack of #{pack.count} bullets"]/)
|> render_click() =~ "Edit ammo"
assert_patch(index_live, Routes.pack_index_path(conn, :edit, pack))
@ -237,7 +237,7 @@ defmodule CanneryWeb.PackLiveTest do
html =
index_live
|> element(~s/a[aria-label="Clone ammo group of #{pack.count} bullets"]/)
|> element(~s/a[aria-label="Clone pack of #{pack.count} bullets"]/)
|> render_click()
assert html =~ "Add Ammo"
@ -261,7 +261,7 @@ defmodule CanneryWeb.PackLiveTest do
html =
index_live
|> element(~s/a[aria-label="Clone ammo group of #{pack.count} bullets"]/)
|> element(~s/a[aria-label="Clone pack of #{pack.count} bullets"]/)
|> render_click()
assert html =~ "Add Ammo"
@ -279,7 +279,7 @@ defmodule CanneryWeb.PackLiveTest do
html =
index_live
|> element(~s/a[aria-label="Clone ammo group of #{pack.count} bullets"]/)
|> element(~s/a[aria-label="Clone pack of #{pack.count} bullets"]/)
|> render_click()
assert html =~ "Add Ammo"
@ -305,7 +305,7 @@ defmodule CanneryWeb.PackLiveTest do
{:ok, index_live, _html} = live(conn, Routes.pack_index_path(conn, :index))
assert index_live
|> element(~s/a[aria-label="Delete ammo group of #{pack.count} bullets"]/)
|> element(~s/a[aria-label="Delete pack of #{pack.count} bullets"]/)
|> render_click()
refute has_element?(index_live, "#pack-#{pack.id}")
@ -334,10 +334,10 @@ defmodule CanneryWeb.PackLiveTest do
defp display_currency(float), do: :erlang.float_to_binary(float, decimals: 2)
end
describe "Index of empty ammo group" do
describe "Index of empty pack" do
setup [:register_and_log_in_user, :create_pack, :create_empty_pack]
test "hides empty ammo groups by default", %{
test "hides empty packs by default", %{
conn: conn,
empty_pack: pack,
current_user: current_user
@ -361,7 +361,7 @@ defmodule CanneryWeb.PackLiveTest do
end
end
describe "Show ammo group" do
describe "Show pack" do
setup [:register_and_log_in_user, :create_pack]
test "displays pack", %{conn: conn, pack: pack} do
@ -375,7 +375,7 @@ defmodule CanneryWeb.PackLiveTest do
{:ok, show_live, _html} = live(conn, Routes.pack_show_path(conn, :show, pack))
assert show_live
|> element(~s/a[aria-label="Edit ammo group of #{pack.count} bullets"]/)
|> element(~s/a[aria-label="Edit pack of #{pack.count} bullets"]/)
|> render_click() =~ "Edit Ammo"
assert_patch(show_live, Routes.pack_show_path(conn, :edit, pack))
@ -414,7 +414,7 @@ defmodule CanneryWeb.PackLiveTest do
end
end
describe "Show ammo group with shot group" do
describe "Show pack with shot group" do
setup [:register_and_log_in_user, :create_pack, :create_shot_group]
test "updates shot_group in listing",

View File

@ -10,8 +10,8 @@ defmodule Cannery.Fixtures do
Accounts.User,
ActivityLog.ShotGroup,
Ammo,
Ammo.Pack,
Ammo.AmmoType,
Ammo.Pack,
Containers,
Containers.Container,
Containers.Tag,