Allow submitting an array of rule_ids to /api/v1/reports
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
bbf3bc2228
commit
574db5b988
9 changed files with 102 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
alias Pleroma.Rule
|
||||
alias Pleroma.Web.AdminAPI
|
||||
alias Pleroma.Web.AdminAPI.Report
|
||||
alias Pleroma.Web.AdminAPI.ReportView
|
||||
|
|
@ -38,7 +39,8 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||
statuses: [],
|
||||
notes: [],
|
||||
state: "open",
|
||||
id: activity.id
|
||||
id: activity.id,
|
||||
rules: []
|
||||
}
|
||||
|
||||
result =
|
||||
|
|
@ -76,7 +78,8 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||
statuses: [StatusView.render("show.json", %{activity: activity})],
|
||||
state: "open",
|
||||
notes: [],
|
||||
id: report_activity.id
|
||||
id: report_activity.id,
|
||||
rules: []
|
||||
}
|
||||
|
||||
result =
|
||||
|
|
@ -168,4 +171,20 @@ defmodule Pleroma.Web.AdminAPI.ReportViewTest do
|
|||
assert report2.id == rendered |> Enum.at(0) |> Map.get(:id)
|
||||
assert report1.id == rendered |> Enum.at(1) |> Map.get(:id)
|
||||
end
|
||||
|
||||
test "renders included rules" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
%{id: id, text: text} = Rule.create(%{text: "Example rule"})
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.report(user, %{
|
||||
account_id: other_user.id,
|
||||
rule_ids: [id]
|
||||
})
|
||||
|
||||
assert %{rules: [%{id: ^id, text: ^text}]} =
|
||||
ReportView.render("show.json", Report.extract_report_info(activity))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.ReportControllerTest do
|
||||
use Pleroma.Web.ConnCase, async: true
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Rule
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
@ -44,6 +46,25 @@ defmodule Pleroma.Web.MastodonAPI.ReportControllerTest do
|
|||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "submit a report with rule_ids", %{
|
||||
conn: conn,
|
||||
target_user: target_user
|
||||
} do
|
||||
%{id: rule_id} = Rule.create(%{text: "There are no rules"})
|
||||
|
||||
assert %{"action_taken" => false, "id" => id} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/reports", %{
|
||||
"account_id" => target_user.id,
|
||||
"forward" => "false",
|
||||
"rule_ids" => [rule_id]
|
||||
})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %Activity{data: %{"rules" => [^rule_id]}} = Activity.get_report(id)
|
||||
end
|
||||
|
||||
test "account_id is required", %{
|
||||
conn: conn,
|
||||
activity: activity
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue