Introduce backend for reports
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -676,6 +676,29 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
|
||||
|
||||
# :error = Transmogrifier.handle_incoming(data)
|
||||
# end
|
||||
|
||||
test "it accepts Flag activities" do
|
||||
%Actor{url: reporter_url} = _reporter = insert(:actor)
|
||||
%Actor{url: reported_url} = reported = insert(:actor)
|
||||
|
||||
%Comment{url: comment_url} = _comment = insert(:comment, actor: reported)
|
||||
|
||||
message = %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
"cc" => [reported_url],
|
||||
"object" => [reported_url, comment_url],
|
||||
"type" => "Flag",
|
||||
"content" => "blocked AND reported!!!",
|
||||
"actor" => reporter_url
|
||||
}
|
||||
|
||||
assert {:ok, activity, _} = Transmogrifier.handle_incoming(message)
|
||||
|
||||
assert activity.data["object"] == [reported_url, comment_url]
|
||||
assert activity.data["content"] == "blocked AND reported!!!"
|
||||
assert activity.data["actor"] == reporter_url
|
||||
assert activity.data["cc"] == [reported_url]
|
||||
end
|
||||
end
|
||||
|
||||
describe "prepare outgoing" do
|
||||
|
||||
43
test/mobilizon/service/admin/action_log_service_test.exs
Normal file
43
test/mobilizon/service/admin/action_log_service_test.exs
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule Mobilizon.Service.Admin.ActionLogServiceTest do
|
||||
@moduledoc """
|
||||
Test the ActionLogService module
|
||||
"""
|
||||
use Mobilizon.DataCase
|
||||
import Mobilizon.Service.Admin.ActionLogService
|
||||
alias Mobilizon.Reports.{Report, Note}
|
||||
alias Mobilizon.Admin.ActionLog
|
||||
import Mobilizon.Factory
|
||||
|
||||
setup do
|
||||
moderator_user = insert(:user, role: :moderator)
|
||||
moderator_actor = insert(:actor, user: moderator_user)
|
||||
{:ok, moderator: moderator_actor}
|
||||
end
|
||||
|
||||
describe "action_log_creation" do
|
||||
test "log a report update", %{moderator: moderator} do
|
||||
%Report{id: _report_id} = report = insert(:report)
|
||||
|
||||
assert {:ok,
|
||||
%ActionLog{
|
||||
target_type: "Elixir.Mobilizon.Reports.Report",
|
||||
target_id: report_id,
|
||||
action: "update",
|
||||
actor: moderator
|
||||
}} = log_action(moderator, "update", report)
|
||||
end
|
||||
|
||||
test "log the creation of a report note", %{moderator: moderator} do
|
||||
%Report{} = report = insert(:report)
|
||||
%Note{id: _note_id} = report = insert(:report_note, report: report)
|
||||
|
||||
assert {:ok,
|
||||
%ActionLog{
|
||||
target_type: "Elixir.Mobilizon.Reports.Note",
|
||||
target_id: note_id,
|
||||
action: "create",
|
||||
actor: moderator
|
||||
}} = log_action(moderator, "create", report)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user