memEx/test/support/fixtures/contexts_fixtures.ex
shibao 1c33cd09c1
Some checks are pending
continuous-integration/drone/push Build is running
improve tagging logic
2022-12-19 22:29:26 -05:00

28 lines
703 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 | tags_string: nil}
end
end