mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-18 10:59:17 +00:00
Merge branch 'reportnote-test' into 'develop'
ReportNote test Closes #2014 See merge request pleroma/pleroma!2839
This commit is contained in:
commit
8fcbfd961d
16
test/report_note_test.exs
Normal file
16
test/report_note_test.exs
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ReportNoteTest do
|
||||
alias Pleroma.ReportNote
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
|
||||
test "create/3" do
|
||||
user = insert(:user)
|
||||
report = insert(:report_activity)
|
||||
assert {:ok, note} = ReportNote.create(user.id, report.id, "naughty boy")
|
||||
assert note.content == "naughty boy"
|
||||
end
|
||||
end
|
|
@ -297,6 +297,30 @@ def follow_activity_factory do
|
|||
}
|
||||
end
|
||||
|
||||
def report_activity_factory(attrs \\ %{}) do
|
||||
user = attrs[:user] || insert(:user)
|
||||
activity = attrs[:activity] || insert(:note_activity)
|
||||
state = attrs[:state] || "open"
|
||||
|
||||
data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
|
||||
"actor" => user.ap_id,
|
||||
"type" => "Flag",
|
||||
"object" => [activity.actor, activity.data["id"]],
|
||||
"published" => DateTime.utc_now() |> DateTime.to_iso8601(),
|
||||
"to" => [],
|
||||
"cc" => [activity.actor],
|
||||
"context" => activity.data["context"],
|
||||
"state" => state
|
||||
}
|
||||
|
||||
%Pleroma.Activity{
|
||||
data: data,
|
||||
actor: data["actor"],
|
||||
recipients: data["to"] ++ data["cc"]
|
||||
}
|
||||
end
|
||||
|
||||
def oauth_app_factory do
|
||||
%Pleroma.Web.OAuth.App{
|
||||
client_name: sequence(:client_name, &"Some client #{&1}"),
|
||||
|
|
Loading…
Reference in a new issue