     assert Map.drop(version, [:id]) == %{
       event: "update",
       item_type: "Company",
-      item_id: Repo.one(first(Company, :id)).id,
+      item_id: first_company.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 = first(Company, :id) |> preload(:people) |> Repo.one

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

    company_count = Repo.all(
      from company in Company,
      select: count(company.id)
    )

    company_ref = 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 == [0]

  end

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

    {:ok, result} =
      ChangesetHelper.update_company(first_company, %{
        city: "Hong Kong",
        website: "http://www.acme.com",
        facebook: "acme.llc"
      }) |> PaperTrail.update()

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

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

    assert company_count == [1]
