   end
 
   test "creating a company creates a company version with correct attributes" do
-    new_company = Company.changeset(%Company{}, %{
-      name: "Acme LLC", is_active: true, city: "Greenwich", people: []
-    })
+    {:ok, result} =
+      %{name: "Acme LLC", is_active: true, city: "Greenwich", people: []}
+      |> ChangesetHelper.new_company()
+      |> PaperTrail.insert(origin: "test")
 
-    {:ok, result} = PaperTrail.insert(new_company, origin: "test")
-
-    company_count = Repo.all(
-      from company in Company,
-      select: count(company.id)
-    )
+    company_count = QueryHelper.company_count() |> Repo.all()
+    version_count = QueryHelper.version_count() |> Repo.all()
+    first_company = QueryHelper.first_company() |> Repo.one()
 
     company = result[:model] |> Map.drop([:__meta__, :__struct__, :inserted_at, :updated_at, :id])
-
-    version_count = Repo.all(
-      from version in PaperTrail.Version,
-      select: count(version.id)
-    )
-
     version = result[:version] |> Map.drop([:__meta__, :__struct__, :inserted_at])
 
     assert company_count == [1]

    assert Map.drop(version, [:id]) == %{
      event: "update",
      item_type: "Company",
      item_id: Repo.one(first(Company, :id)).id,
      item_changes: %{city: "Hong Kong", website: "http://www.acme.com", facebook: "acme.llc"},
      origin: nil,
      originator_id: nil,

  end

  test "deleting a company creates a company version with correct attributes" do
    company = QueryHelper.first_company() |> Repo.one()

    {:ok, result} =
      company
      |> PaperTrail.delete()

    company_count = QueryHelper.company_count() |> Repo.all()
    version_count = QueryHelper.version_count() |> Repo.all()

    company_ref = result[:model] |> Map.drop([:__meta__, :__struct__, :inserted_at, :updated_at, :id])
    version = result[:version] |> Map.drop([:__meta__, :__struct__, :inserted_at])

    assert company_count == [0]
