diff options
author | rinpatch <rinpatch@sdf.org> | 2019-05-21 20:40:35 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-05-21 20:40:35 +0300 |
commit | 63b0b7190cb652cd27d236e3f9daaaf5e50701a6 (patch) | |
tree | cf013c3dc45dfd2241202d8ccbc22d1f3cc3610b /test | |
parent | ff61d345020b9ee79b243fb8d23a37a06cc41b8e (diff) | |
download | pleroma-63b0b7190cb652cd27d236e3f9daaaf5e50701a6.tar.gz pleroma-63b0b7190cb652cd27d236e3f9daaaf5e50701a6.zip |
MastoAPI: Add GET /api/v1/polls/:id
Diffstat (limited to 'test')
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 4f332f83c..0d56b6ff2 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -3453,4 +3453,48 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert json_response(conn, 403) == %{"error" => "Rate limit exceeded."} end end + + describe "GET /api/v1/polls/:id" do + test "returns poll entity for object id", %{conn: conn} do + user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => "Pleroma does", + "poll" => %{"options" => ["what Mastodon't", "n't what Mastodoes"], "expires_in" => 20} + }) + + object = Object.normalize(activity) + + conn = + conn + |> assign(:user, user) + |> get("/api/v1/polls/#{object.id}") + + response = json_response(conn, 200) + id = object.id + assert %{"id" => ^id, "expired" => false, "multiple" => false} = response + end + + test "does not expose polls for private statuses", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => "Pleroma does", + "poll" => %{"options" => ["what Mastodon't", "n't what Mastodoes"], "expires_in" => 20}, + "visibility" => "private" + }) + + object = Object.normalize(activity) + + conn = + conn + |> assign(:user, other_user) + |> get("/api/v1/polls/#{object.id}") + + assert json_response(conn, 404) + end + end end |