forked from shibao/cannery
		
	rename ammo groups to packs
This commit is contained in:
		@@ -15,13 +15,13 @@ defmodule CanneryWeb.ExportControllerTest do
 | 
			
		||||
    container = container_fixture(current_user)
 | 
			
		||||
    tag = tag_fixture(current_user)
 | 
			
		||||
    Containers.add_tag!(container, tag, current_user)
 | 
			
		||||
    {1, [ammo_group]} = ammo_group_fixture(ammo_type, container, current_user)
 | 
			
		||||
    shot_group = shot_group_fixture(current_user, ammo_group)
 | 
			
		||||
    ammo_group = ammo_group |> Repo.reload!()
 | 
			
		||||
    {1, [pack]} = pack_fixture(ammo_type, container, current_user)
 | 
			
		||||
    shot_group = shot_group_fixture(current_user, pack)
 | 
			
		||||
    pack = pack |> Repo.reload!()
 | 
			
		||||
 | 
			
		||||
    %{
 | 
			
		||||
      ammo_type: ammo_type,
 | 
			
		||||
      ammo_group: ammo_group,
 | 
			
		||||
      pack: pack,
 | 
			
		||||
      container: container,
 | 
			
		||||
      shot_group: shot_group,
 | 
			
		||||
      tag: tag
 | 
			
		||||
@@ -36,24 +36,24 @@ defmodule CanneryWeb.ExportControllerTest do
 | 
			
		||||
      current_user: current_user,
 | 
			
		||||
      container: container,
 | 
			
		||||
      ammo_type: ammo_type,
 | 
			
		||||
      ammo_group: ammo_group,
 | 
			
		||||
      pack: pack,
 | 
			
		||||
      shot_group: shot_group,
 | 
			
		||||
      tag: tag
 | 
			
		||||
    } do
 | 
			
		||||
      conn = get(conn, Routes.export_path(conn, :export, :json))
 | 
			
		||||
 | 
			
		||||
      ideal_ammo_group = %{
 | 
			
		||||
        "ammo_type_id" => ammo_group.ammo_type_id,
 | 
			
		||||
        "container_id" => ammo_group.container_id,
 | 
			
		||||
        "count" => ammo_group.count,
 | 
			
		||||
        "id" => ammo_group.id,
 | 
			
		||||
        "notes" => ammo_group.notes,
 | 
			
		||||
        "price_paid" => ammo_group.price_paid,
 | 
			
		||||
        "staged" => ammo_group.staged,
 | 
			
		||||
        "used_count" => ammo_group |> ActivityLog.get_used_count(current_user),
 | 
			
		||||
        "original_count" => ammo_group |> Ammo.get_original_count(current_user),
 | 
			
		||||
        "cpr" => ammo_group |> Ammo.get_cpr(current_user),
 | 
			
		||||
        "percentage_remaining" => ammo_group |> Ammo.get_percentage_remaining(current_user)
 | 
			
		||||
      ideal_pack = %{
 | 
			
		||||
        "ammo_type_id" => pack.ammo_type_id,
 | 
			
		||||
        "container_id" => pack.container_id,
 | 
			
		||||
        "count" => pack.count,
 | 
			
		||||
        "id" => pack.id,
 | 
			
		||||
        "notes" => pack.notes,
 | 
			
		||||
        "price_paid" => pack.price_paid,
 | 
			
		||||
        "staged" => pack.staged,
 | 
			
		||||
        "used_count" => pack |> ActivityLog.get_used_count(current_user),
 | 
			
		||||
        "original_count" => pack |> Ammo.get_original_count(current_user),
 | 
			
		||||
        "cpr" => pack |> Ammo.get_cpr(current_user),
 | 
			
		||||
        "percentage_remaining" => pack |> Ammo.get_percentage_remaining(current_user)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      ideal_ammo_type = %{
 | 
			
		||||
@@ -82,9 +82,8 @@ defmodule CanneryWeb.ExportControllerTest do
 | 
			
		||||
        "average_cost" => ammo_type |> Ammo.get_average_cost_for_ammo_type(current_user),
 | 
			
		||||
        "round_count" => ammo_type |> Ammo.get_round_count_for_ammo_type(current_user),
 | 
			
		||||
        "used_count" => ammo_type |> ActivityLog.get_used_count_for_ammo_type(current_user),
 | 
			
		||||
        "ammo_group_count" => ammo_type |> Ammo.get_ammo_groups_count_for_type(current_user),
 | 
			
		||||
        "total_ammo_group_count" =>
 | 
			
		||||
          ammo_type |> Ammo.get_ammo_groups_count_for_type(current_user, true)
 | 
			
		||||
        "pack_count" => ammo_type |> Ammo.get_packs_count_for_type(current_user),
 | 
			
		||||
        "total_pack_count" => ammo_type |> Ammo.get_packs_count_for_type(current_user, true)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      ideal_container = %{
 | 
			
		||||
@@ -101,13 +100,12 @@ defmodule CanneryWeb.ExportControllerTest do
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "type" => container.type,
 | 
			
		||||
        "ammo_group_count" =>
 | 
			
		||||
          container |> Ammo.get_ammo_groups_count_for_container!(current_user),
 | 
			
		||||
        "pack_count" => container |> Ammo.get_packs_count_for_container!(current_user),
 | 
			
		||||
        "round_count" => container |> Ammo.get_round_count_for_container!(current_user)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      ideal_shot_group = %{
 | 
			
		||||
        "ammo_group_id" => shot_group.ammo_group_id,
 | 
			
		||||
        "pack_id" => shot_group.pack_id,
 | 
			
		||||
        "count" => shot_group.count,
 | 
			
		||||
        "date" => to_string(shot_group.date),
 | 
			
		||||
        "id" => shot_group.id,
 | 
			
		||||
@@ -126,7 +124,7 @@ defmodule CanneryWeb.ExportControllerTest do
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      json_resp = conn |> json_response(200)
 | 
			
		||||
      assert %{"ammo_groups" => [^ideal_ammo_group]} = json_resp
 | 
			
		||||
      assert %{"packs" => [^ideal_pack]} = json_resp
 | 
			
		||||
      assert %{"ammo_types" => [^ideal_ammo_type]} = json_resp
 | 
			
		||||
      assert %{"containers" => [^ideal_container]} = json_resp
 | 
			
		||||
      assert %{"shot_groups" => [^ideal_shot_group]} = json_resp
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user