memEx/test/support/fixtures/notes_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
636 B
Elixir

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