Add starts_at, ends_at and all_day parameters
This commit is contained in:
parent
fcf3c9057e
commit
cf8334dbc1
6 changed files with 42 additions and 22 deletions
|
|
@ -80,15 +80,29 @@ defmodule Pleroma.Web.AdminAPI.AnnouncementControllerTest do
|
|||
test "it creates an announcement", %{conn: conn} do
|
||||
content = "test post announcement api"
|
||||
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
starts_at = NaiveDateTime.add(now, -10, :second)
|
||||
ends_at = NaiveDateTime.add(now, 10, :second)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/pleroma/admin/announcements", %{
|
||||
"content" => content
|
||||
"content" => content,
|
||||
"starts_at" => NaiveDateTime.to_iso8601(starts_at),
|
||||
"ends_at" => NaiveDateTime.to_iso8601(ends_at),
|
||||
"all_day" => true
|
||||
})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert %{"content" => ^content} = response
|
||||
assert %{"content" => ^content, "all_day" => true} = response
|
||||
|
||||
announcement = Pleroma.Announcement.get_by_id(response["id"])
|
||||
|
||||
assert not is_nil(announcement)
|
||||
|
||||
assert NaiveDateTime.compare(announcement.starts_at, starts_at) == :eq
|
||||
assert NaiveDateTime.compare(announcement.ends_at, ends_at) == :eq
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ defmodule Pleroma.Factory do
|
|||
|
||||
def announcement_factory(params \\ %{}, data \\ %{}) do
|
||||
%Pleroma.Announcement{
|
||||
data: Map.merge(%{"content" => "test announcement"}, data)
|
||||
data: Map.merge(%{"content" => "test announcement", "all_day" => false}, data)
|
||||
}
|
||||
|> Map.merge(params)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue