try to fix update #265
2 changed files with 13 additions and 1 deletions
|
@ -27,6 +27,7 @@ defmodule ChiyaWeb.Indie.Micropub do
|
||||||
note = Chiya.Notes.get_note_by_slug_preloaded(slug)
|
note = Chiya.Notes.get_note_by_slug_preloaded(slug)
|
||||||
|
|
||||||
if is_nil(note) do
|
if is_nil(note) do
|
||||||
|
Logger.error("Note with #{note_url} was not found.")
|
||||||
{:error, :invalid_request}
|
{:error, :invalid_request}
|
||||||
else
|
else
|
||||||
{:ok, note}
|
{:ok, note}
|
||||||
|
|
|
@ -33,11 +33,22 @@ defmodule ChiyaWeb.MicropubTest do
|
||||||
assert note.content == "replaced content"
|
assert note.content == "replaced content"
|
||||||
end
|
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
|
test "updates a note by adding categories" do
|
||||||
note = note_fixture()
|
note = note_fixture()
|
||||||
|
|
||||||
assert {:ok, %Note{} = note} =
|
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
|
assert Enum.empty?(note.tags) == false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue