memEx/test/support/fixtures/contexts_fixtures.ex
2022-11-26 20:38:31 -05:00

28 lines
667 B
Elixir

defmodule Memex.ContextsFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `Memex.Contexts` context.
"""
import Memex.Fixtures
alias Memex.{Accounts.User, Contexts, Contexts.Context}
@doc """
Generate a context.
"""
@spec context_fixture(User.t()) :: Context.t()
@spec context_fixture(attrs :: map(), User.t()) :: Context.t()
def context_fixture(attrs \\ %{}, user) do
{:ok, context} =
attrs
|> Enum.into(%{
content: "some content",
tag: [],
slug: random_slug(),
visibility: :private
})
|> Contexts.create_context(user)
context
end
end