Show only visible announcements in MastodonAPI
This commit is contained in:
parent
cf8334dbc1
commit
d569694ae9
|
@ -46,7 +46,7 @@ def index(conn, _params) do
|
|||
end
|
||||
|
||||
defp all_visible do
|
||||
Announcement.list_all()
|
||||
Announcement.list_all_visible()
|
||||
end
|
||||
|
||||
@doc "POST /api/v1/announcements/:id/dismiss"
|
||||
|
|
|
@ -23,6 +23,30 @@ test "it lists all announcements" do
|
|||
refute Map.has_key?(Enum.at(response, 0), "read")
|
||||
end
|
||||
|
||||
test "it does not list announcements starting after current time" do
|
||||
time = NaiveDateTime.utc_now() |> NaiveDateTime.add(999999, :second)
|
||||
insert(:announcement, starts_at: time)
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|> get("/api/v1/announcements")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert [] = response
|
||||
end
|
||||
|
||||
test "it does not list announcements ending before current time" do
|
||||
time = NaiveDateTime.utc_now() |> NaiveDateTime.add(-999999, :second)
|
||||
insert(:announcement, ends_at: time)
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|> get("/api/v1/announcements")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert [] = response
|
||||
end
|
||||
|
||||
test "when authenticated, also expose read property" do
|
||||
%{id: id} = insert(:announcement)
|
||||
|
||||
|
|
Loading…
Reference in New Issue