memEx/test/support/fixtures/notes_fixtures.ex
shibao 571f6fffdb
Some checks are pending
continuous-integration/drone/push Build is running
improve tagging logic
2022-12-19 22:34:00 -05:00

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