diff --git a/test/support/helpers.ex b/test/support/helpers.ex index fba72dc..5eda7a6 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -40,4 +40,15 @@ defmodule DecentralisedBookIndex.Helpers do |> DateTime.add(seconds) |> DateTime.to_iso8601() end + + @doc """ + Logs the given `user` into the `conn`. + + It returns an updated `conn`. + """ + def log_in_user(conn, user) do + conn + |> Phoenix.ConnTest.init_test_session(%{}) + |> AshAuthentication.Plug.Helpers.store_in_session(user) + end end