memEx/test/support/fixtures/contexts_fixtures.ex
shibao c3ceb877b2
All checks were successful
continuous-integration/drone/push Build is passing
search tags when on click
2022-12-15 22:52:42 -05:00

28 lines
681 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",
tags: ["example-tag"],
slug: random_slug(),
visibility: :private
})
|> Contexts.create_context(user)
context
end
end