diff --git a/test/all_test.exs b/test/all_test.exs index 791e3bb..64b834a 100644 --- a/test/all_test.exs +++ b/test/all_test.exs @@ -14,10 +14,18 @@ defmodule AlogTest.AllTest do test "does not include old items" do {:ok, user} = %User{} |> User.changeset(Helpers.user_1_params()) |> User.insert() {:ok, _} = %User{} |> User.changeset(Helpers.user_2_params()) |> User.insert() - {:ok, user_updated} = user |> User.changeset(%{postcode: "W2 3EC"}) |> User.update() + {:ok, _} = user |> User.changeset(%{postcode: "W2 3EC"}) |> User.update() assert length(User.all()) == 2 - assert user.inserted_at == user_updated.inserted_at + end + + test "all return inserted_at original value" do + {:ok, user} = %User{} |> User.changeset(Helpers.user_3_params()) |> User.insert() + {:ok, user_updated} = user |> User.changeset(%{postcode: "W2 3EC"}) |> User.update() + + [user_all] = User.all() + assert user_all.inserted_at == user.inserted_at + assert user_all.postcode == user_updated.postcode end end end diff --git a/test/get_by_test.exs b/test/get_by_test.exs index 7bf938a..34fb9ee 100644 --- a/test/get_by_test.exs +++ b/test/get_by_test.exs @@ -38,7 +38,7 @@ defmodule AlogTest.GetByTest do test "does not retrieve outdated results" do {:ok, user} = %User{} |> User.changeset(Helpers.user_1_params()) |> User.insert() - {:ok, updated_user} = user |> User.changeset(%{postcode: "EC3 RST"}) |> User.update() + {:ok, _updated_user} = user |> User.changeset(%{postcode: "EC3 RST"}) |> User.update() assert User.get_by(postcode: "E2 0SY") == nil end @@ -58,7 +58,7 @@ defmodule AlogTest.GetByTest do |> User.changeset(Map.put(Helpers.user_2_params(), :postcode, "E2 0SY")) |> User.insert() - {:ok, updated_user_2} = user_2 |> User.changeset(%{postcode: "EC3 RST"}) |> User.update() + {:ok, _} = user_2 |> User.changeset(%{postcode: "EC3 RST"}) |> User.update() assert User.get_by(postcode: "E2 0SY") == user end diff --git a/test/support/helpers.ex b/test/support/helpers.ex index 2f6e5b5..2374956 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -6,6 +6,8 @@ defmodule Alog.TestApp.Helpers do def user_2_params(), do: %{name: "Loki", username: "mschfmkr", postcode: "E1 6DR"} + def user_3_params(), do: %{name: "Bob", username: "bobuser", postcode: "E1 7DR"} + def seed_data() do {:ok, item_type} = %ItemType{} |> ItemType.changeset(%{type: "Weapon"}) |> ItemType.insert()