2023-07-17 20:22:58 +02:00
|
|
|
defmodule ChiyaWeb.MicropubTest do
|
|
|
|
use Chiya.DataCase
|
|
|
|
|
|
|
|
alias ChiyaWeb.Indie.Micropub
|
2023-07-17 22:24:17 +02:00
|
|
|
alias Chiya.Notes.Note
|
|
|
|
alias Chiya.Channels.Channel
|
2023-07-17 20:22:58 +02:00
|
|
|
|
|
|
|
@valid_props %{
|
|
|
|
"content" => ["this is a test"]
|
|
|
|
}
|
|
|
|
|
|
|
|
describe "create_note/3" do
|
|
|
|
test "creates a note with valid attributes" do
|
|
|
|
assert {:ok, :created, url} =
|
2023-07-17 22:24:17 +02:00
|
|
|
Micropub.create_note("entry", @valid_props)
|
2023-07-17 20:22:58 +02:00
|
|
|
|
2023-07-17 22:24:17 +02:00
|
|
|
note = Chiya.Notes.get_note_by_slug_preloaded("this-is-a-test")
|
|
|
|
|
|
|
|
assert url =~ note.slug
|
|
|
|
assert %Note{} = note
|
|
|
|
assert [%Channel{}] = note.channels
|
2023-07-17 20:22:58 +02:00
|
|
|
end
|
|
|
|
end
|
2023-07-17 22:24:17 +02:00
|
|
|
|
|
|
|
setup do
|
|
|
|
{:ok, channel} =
|
|
|
|
Chiya.Channels.create_channel(%{
|
|
|
|
name: "Home",
|
|
|
|
content: "Home channel"
|
|
|
|
})
|
|
|
|
|
|
|
|
settings = Chiya.Site.get_settings()
|
|
|
|
|
|
|
|
Chiya.Site.update_setting(settings, %{
|
|
|
|
home_channel_id: channel.id,
|
|
|
|
default_channel_id: channel.id,
|
|
|
|
micropub_channel_id: channel.id,
|
|
|
|
wiki_channel_id: channel.id
|
|
|
|
})
|
|
|
|
|
|
|
|
:ok
|
|
|
|
end
|
2023-07-17 20:22:58 +02:00
|
|
|
end
|