From 9502748dc9804695ef0c59222067ae537dd97af6 Mon Sep 17 00:00:00 2001 From: Inhji Date: Sun, 20 Aug 2023 23:47:00 +0200 Subject: [PATCH] try to fix update --- lib/chiya_web/indie/micropub.ex | 1 + test/chiya_web/indie/micropub_test.exs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/chiya_web/indie/micropub.ex b/lib/chiya_web/indie/micropub.ex index effae15..b7fb9b2 100644 --- a/lib/chiya_web/indie/micropub.ex +++ b/lib/chiya_web/indie/micropub.ex @@ -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} diff --git a/test/chiya_web/indie/micropub_test.exs b/test/chiya_web/indie/micropub_test.exs index 12ca0ae..1d61c6b 100644 --- a/test/chiya_web/indie/micropub_test.exs +++ b/test/chiya_web/indie/micropub_test.exs @@ -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