Test pinned private statuses in AccountController
This commit is contained in:
parent
88c21b9282
commit
00523bdf5e
|
@ -5,7 +5,9 @@
|
||||||
defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
|
alias Pleroma.Object
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
alias Pleroma.Tests.ObanHelpers
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||||
|
@ -404,15 +406,6 @@ test "gets users statuses", %{conn: conn} do
|
||||||
assert id_two == to_string(activity.id)
|
assert id_two == to_string(activity.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "unimplemented pinned statuses feature", %{conn: conn} do
|
|
||||||
note = insert(:note_activity)
|
|
||||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
|
||||||
|
|
||||||
conn = get(conn, "/api/v1/accounts/#{user.id}/statuses?pinned=true")
|
|
||||||
|
|
||||||
assert json_response_and_validate_schema(conn, 200) == []
|
|
||||||
end
|
|
||||||
|
|
||||||
test "gets an users media, excludes reblogs", %{conn: conn} do
|
test "gets an users media, excludes reblogs", %{conn: conn} do
|
||||||
note = insert(:note_activity)
|
note = insert(:note_activity)
|
||||||
user = User.get_cached_by_ap_id(note.data["actor"])
|
user = User.get_cached_by_ap_id(note.data["actor"])
|
||||||
|
@ -1038,6 +1031,35 @@ test "returns pinned statuses", %{conn: conn, user: user, activity: %{id: activi
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "view pinned private statuses" do
|
||||||
|
user = insert(:user)
|
||||||
|
reader = insert(:user)
|
||||||
|
|
||||||
|
# Create a private status and pin it
|
||||||
|
{:ok, %{id: activity_id} = activity} =
|
||||||
|
CommonAPI.post(user, %{status: "psst", visibility: "private"})
|
||||||
|
|
||||||
|
%{data: %{"id" => object_ap_id}} = Object.normalize(activity)
|
||||||
|
{:ok, _} = User.add_pinned_object_id(user, object_ap_id)
|
||||||
|
|
||||||
|
%{conn: conn} = oauth_access(["read:statuses"], user: reader)
|
||||||
|
|
||||||
|
# A non-follower can't see the pinned status
|
||||||
|
assert [] ==
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/accounts/#{user.id}/statuses?pinned=true")
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
# Follow the user, then the pinned status can be seen
|
||||||
|
CommonAPI.follow(reader, user)
|
||||||
|
ObanHelpers.perform_all()
|
||||||
|
|
||||||
|
assert [%{"id" => ^activity_id, "pinned" => true}] =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/accounts/#{user.id}/statuses?pinned=true")
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
end
|
||||||
|
|
||||||
test "blocking / unblocking a user" do
|
test "blocking / unblocking a user" do
|
||||||
%{conn: conn} = oauth_access(["follow"])
|
%{conn: conn} = oauth_access(["follow"])
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
|
Loading…
Reference in New Issue