try to fix update

This commit is contained in:
Inhji 2023-08-20 23:47:00 +02:00
parent 4d1d5e72be
commit 9502748dc9
2 changed files with 13 additions and 1 deletions

View file

@ -27,6 +27,7 @@ defmodule ChiyaWeb.Indie.Micropub do
note = Chiya.Notes.get_note_by_slug_preloaded(slug)
if is_nil(note) do
Logger.error("Note with #{note_url} was not found.")
{:error, :invalid_request}
else
{:ok, note}

View file

@ -33,11 +33,22 @@ defmodule ChiyaWeb.MicropubTest do
assert note.content == "replaced content"
end
test "updates a note by replacing name" do
note = note_fixture()
assert {:ok, %Note{} = note} =
Micropub.update_note(note, %{"name" => ["replaced name"]}, %{}, %{})
assert note.name == "replaced name"
end
test "updates a note by adding categories" do
note = note_fixture()
assert {:ok, %Note{} = note} =
Micropub.update_note(note, %{}, %{"category" => ["foo", "bar"]}, %{})
Micropub.update_note(note, %{"category" => ["foo", "bar"]}, %{}, %{})
IO.inspect(note)
assert Enum.empty?(note.tags) == false
end