Merge pull request 'Federate votersCount correctly' (#7858) from mkljczk/pleroma:poll-voters-count into develop

Reviewed-on: https://git.pleroma.social/pleroma/pleroma/pulls/7858
This commit is contained in:
nicole mikołajczyk 2026-03-26 11:55:36 +00:00
commit 9e22baa66a
7 changed files with 46 additions and 1 deletions

View file

@ -170,4 +170,23 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
end
test "it displays voters count for a poll" do
user = insert(:user)
other_user = insert(:user)
{:ok, activity} =
CommonAPI.post(user, %{
status: "???",
poll: %{expires_in: 10, options: ["yes", "no"]}
})
object = Object.normalize(activity, fetch: false)
{:ok, _, _} = CommonAPI.vote(object, other_user, [1])
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
refute Map.has_key?(modified["object"], "voters")
assert modified["object"]["votersCount"] == 1
end
end

View file

@ -167,7 +167,14 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
} = PollView.render("show.json", %{object: object})
end
test "that poll is non anonymous" do
test "displays correct voters count" do
object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true)
result = PollView.render("show.json", %{object: object})
assert result[:voters_count] == 14
end
test "detects that poll is non anonymous" do
object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true)
result = PollView.render("show.json", %{object: object})