diff --git a/example/mix.lock b/example/mix.lock index 66cae8c1..640b1e49 100644 --- a/example/mix.lock +++ b/example/mix.lock @@ -2,7 +2,7 @@ "db_connection": {:hex, :db_connection, "1.0.0-rc.3", "d9ceb670fe300271140af46d357b669983cd16bc0d01206d7d3222dde56cf038", [:mix], [{:sbroker, "~> 1.0.0-beta.3", [hex: :sbroker, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:connection, "~> 1.0.2", [hex: :connection, optional: false]}]}, "decimal": {:hex, :decimal, "1.1.2", "79a769d4657b2d537b51ef3c02d29ab7141d2b486b516c109642d453ee08e00c", [:mix], []}, "ecto": {:hex, :ecto, "2.0.2", "b02331c1f20bbe944dbd33c8ecd8f1ccffecc02e344c4471a891baf3a25f5406", [:mix], [{:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: true]}, {:sbroker, "~> 1.0-beta", [hex: :sbroker, optional: true]}, {:mariaex, "~> 0.7.7", [hex: :mariaex, optional: true]}, {:postgrex, "~> 0.11.2", [hex: :postgrex, optional: true]}, {:db_connection, "~> 1.0-rc.2", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}]}, - "paper_trail": {:hex, :paper_trail, "0.0.8", "9be51d594ebdc1a228ad3f3b5cbafcca5d5e8e8661eb44319fd011c510ef2628", [:mix], [{:poison, "2.1.0", [hex: :poison, optional: false]}, {:ecto, "~> 2.0.2", [hex: :ecto, optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, optional: false]}]}, + "paper_trail": {:hex, :paper_trail, "0.0.9", "4e9342ee2bae6df9c80a2a3b5619e8df2a0113a545e5671d964ffa5dc9c37b69", [:mix], [{:poison, "2.1.0", [hex: :poison, optional: false]}, {:ecto, "~> 2.0.2", [hex: :ecto, optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, optional: false]}]}, "poison": {:hex, :poison, "2.1.0", "f583218ced822675e484648fa26c933d621373f01c6c76bd00005d7bd4b82e27", [:mix], []}, "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}, "postgrex": {:hex, :postgrex, "0.11.2", "139755c1359d3c5c6d6e8b1ea72556d39e2746f61c6ddfb442813c91f53487e8", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.0-rc", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]}} diff --git a/example/test/company_test.exs b/example/test/company_test.exs index f7c3756c..49eb77c3 100644 --- a/example/test/company_test.exs +++ b/example/test/company_test.exs @@ -155,8 +155,7 @@ defmodule CompanyTest do address: nil, facebook: "acme.llc", twitter: nil, - founded_in: nil, - people: [] + founded_in: nil }, meta: nil } diff --git a/example/test/person_test.exs b/example/test/person_test.exs index ddf8bb55..23ed957a 100644 --- a/example/test/person_test.exs +++ b/example/test/person_test.exs @@ -135,7 +135,7 @@ defmodule PersonTest do end test "deleting a person creates a person version with correct attributes" do - person = first(Person, :id) |> Repo.one + person = first(Person, :id) |> preload(:company) |> Repo.one {:ok, result} = PaperTrail.delete(person) @@ -153,32 +153,25 @@ defmodule PersonTest do version = result[:version] |> Map.drop([:__meta__, :__struct__, :inserted_at]) - assert person_count == [1] + assert person_count == [0] assert version_count == [3] - assert person_ref == %{ - + assert Map.drop(version, [:id]) == %{ + event: "destroy", + item_type: "Person", + item_id: person.id, + item_changes: %{ + id: person.id, + inserted_at: person.inserted_at, + updated_at: person.updated_at, + first_name: "Isaac", + last_name: "Nakri", + gender: true, + visit_count: 10, + birthdate: elem(Ecto.Date.cast(~D[1992-04-01]), 1), + company_id: person.company.id + }, + meta: nil } - - # assert Map.drop(version, [:id]) == %{ - # event: "destroy", - # item_type: "Company", - # item_id: company.id, - # item_changes: %{ - # id: company.id, - # inserted_at: company.inserted_at, - # updated_at: company.updated_at, - # name: "Acme LLC", - # is_active: true, - # website: "http://www.acme.com", - # city: "Hong Kong", - # address: nil, - # facebook: "acme.llc", - # twitter: nil, - # founded_in: nil, - # people: [] - # }, - # meta: nil - # } end end diff --git a/lib/paper_trail.ex b/lib/paper_trail.ex index 447a4f22..5dd44537 100644 --- a/lib/paper_trail.ex +++ b/lib/paper_trail.ex @@ -56,8 +56,6 @@ defmodule PaperTrail do end defp make_version_struct(%{event: "create"}, model, meta) do - IO.puts "make_version_struct called" - filter_item_changes(model) |> inspect |> IO.puts %Version{ event: "create", item_type: model.__struct__ |> Module.split |> List.last, @@ -105,11 +103,7 @@ defmodule PaperTrail do Multi.new |> Multi.delete(:model, struct) |> Multi.run(:version, fn %{model: model} -> - IO.puts("model is :") - model |> inspect |> IO.puts version = make_version_struct(%{event: "destroy"}, model, meta) - IO.puts "version is" - version |> inspect |> IO.puts Repo.insert(version) end) |> Repo.transaction diff --git a/mix.exs b/mix.exs index 69ba22b5..f24d14b0 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule PaperTrail.Mixfile do def project do [app: :paper_trail, - version: "0.0.9", + version: "0.1.0", elixir: "~> 1.3", description: description, build_embedded: Mix.env == :prod,