memEx/test/support/fixtures/contexts_fixtures.ex

27 lines
643 B
Elixir
Raw Normal View History

2022-07-25 20:11:08 -04:00
defmodule Memex.ContextsFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `Memex.Contexts` context.
"""
2022-11-24 12:44:34 -05:00
alias Memex.{Accounts.User, Contexts, Contexts.Context}
2022-07-25 20:11:08 -04:00
@doc """
Generate a context.
"""
2022-11-24 12:44:34 -05:00
@spec context_fixture(User.t()) :: Context.t()
@spec context_fixture(attrs :: map(), User.t()) :: Context.t()
def context_fixture(attrs \\ %{}, user) do
2022-07-25 20:11:08 -04:00
{:ok, context} =
attrs
|> Enum.into(%{
content: "some content",
tag: [],
title: "some title",
2022-11-24 12:44:34 -05:00
visibility: :private
2022-07-25 20:11:08 -04:00
})
2022-11-24 12:44:34 -05:00
|> Contexts.create_context(user)
2022-07-25 20:11:08 -04:00
context
end
end