improve Ammo.get_round_count
This commit is contained in:
@ -343,24 +343,24 @@ defmodule Cannery.AmmoTest do
|
||||
assert %{^another_type_id => 25.0} = average_costs
|
||||
end
|
||||
|
||||
test "get_round_count_for_type/2 gets accurate round count for type",
|
||||
test "get_round_count/2 gets accurate round count for type",
|
||||
%{type: type, current_user: current_user, container: container} do
|
||||
another_type = type_fixture(current_user)
|
||||
assert 0 = Ammo.get_round_count_for_type(another_type, current_user)
|
||||
assert 0 = Ammo.get_round_count(current_user, type_id: another_type.id)
|
||||
|
||||
{1, [first_pack]} = pack_fixture(%{count: 1}, type, container, current_user)
|
||||
|
||||
assert 1 = Ammo.get_round_count_for_type(type, current_user)
|
||||
assert 1 = Ammo.get_round_count(current_user, type_id: type.id)
|
||||
|
||||
{1, [pack]} = pack_fixture(%{count: 50}, type, container, current_user)
|
||||
|
||||
assert 51 = Ammo.get_round_count_for_type(type, current_user)
|
||||
assert 51 = Ammo.get_round_count(current_user, type_id: type.id)
|
||||
|
||||
shot_record_fixture(%{count: 26}, current_user, pack)
|
||||
assert 25 = Ammo.get_round_count_for_type(type, current_user)
|
||||
assert 25 = Ammo.get_round_count(current_user, type_id: type.id)
|
||||
|
||||
shot_record_fixture(%{count: 1}, current_user, first_pack)
|
||||
assert 24 = Ammo.get_round_count_for_type(type, current_user)
|
||||
assert 24 = Ammo.get_round_count(current_user, type_id: type.id)
|
||||
end
|
||||
|
||||
test "get_round_count_for_types/2 gets accurate round counts for types", %{
|
||||
@ -635,18 +635,18 @@ defmodule Cannery.AmmoTest do
|
||||
assert %{^another_container_id => 1} = packs_count
|
||||
end
|
||||
|
||||
test "get_round_count_for_container!/2 gets accurate total round count for container",
|
||||
test "get_round_count/2 gets accurate total round count for container_id",
|
||||
%{type: type, current_user: current_user, container: container} do
|
||||
{1, [first_pack]} = pack_fixture(%{count: 5}, type, container, current_user)
|
||||
|
||||
assert 5 = container |> Ammo.get_round_count_for_container!(current_user)
|
||||
assert 5 = Ammo.get_round_count(current_user, container_id: container.id)
|
||||
|
||||
{25, _packs} = pack_fixture(%{count: 5}, 25, type, container, current_user)
|
||||
|
||||
assert 130 = container |> Ammo.get_round_count_for_container!(current_user)
|
||||
assert 130 = Ammo.get_round_count(current_user, container_id: container.id)
|
||||
|
||||
shot_record_fixture(%{count: 5}, current_user, first_pack)
|
||||
assert 125 = container |> Ammo.get_round_count_for_container!(current_user)
|
||||
assert 125 = Ammo.get_round_count(current_user, container_id: container.id)
|
||||
end
|
||||
|
||||
test "get_round_count_for_containers/2 gets accurate total round count for containers",
|
||||
|
@ -91,7 +91,7 @@ defmodule CanneryWeb.ExportControllerTest do
|
||||
"shot_charge_weight" => type.shot_charge_weight,
|
||||
"dram_equivalent" => type.dram_equivalent,
|
||||
"average_cost" => type |> Ammo.get_average_cost_for_type(current_user),
|
||||
"round_count" => type |> Ammo.get_round_count_for_type(current_user),
|
||||
"round_count" => Ammo.get_round_count(current_user, type_id: type.id),
|
||||
"used_count" => ActivityLog.get_used_count(current_user, type_id: type.id),
|
||||
"pack_count" => Ammo.get_packs_count(current_user, type_id: type.id),
|
||||
"total_pack_count" =>
|
||||
@ -113,7 +113,7 @@ defmodule CanneryWeb.ExportControllerTest do
|
||||
],
|
||||
"type" => container.type,
|
||||
"pack_count" => Ammo.get_packs_count(current_user, container_id: container.id),
|
||||
"round_count" => container |> Ammo.get_round_count_for_container!(current_user)
|
||||
"round_count" => Ammo.get_round_count(current_user, container_id: container.id)
|
||||
}
|
||||
|
||||
ideal_shot_record = %{
|
||||
|
Reference in New Issue
Block a user