defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
use Pleroma.DataCase
alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.{Activity, Object, User}
alias Pleroma.Builders.ActivityBuilder
import Pleroma.Factory
describe "insertion" do
+ test "returns the activity if one with the same id is already in" do
+ activity = insert(:note_activity)
+ {:ok, new_activity}= ActivityPub.insert(activity.data)
+
+ assert activity == new_activity
+ end
+
test "inserts a given map into the activity database, giving it an id if it has none." do
data = %{
"ok" => true
describe "fetch activities in context" do
test "retrieves activities that have a given context" do
- {:ok, activity} = ActivityBuilder.insert(%{"context" => "2hu"})
- {:ok, activity_two} = ActivityBuilder.insert(%{"context" => "2hu"})
- {:ok, _activity_three} = ActivityBuilder.insert(%{"context" => "3hu"})
+ {:ok, activity} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
+ {:ok, activity_two} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
+ {:ok, _activity_three} = ActivityBuilder.insert(%{"type" => "Create", "context" => "3hu"})
+ {:ok, _activity_four} = ActivityBuilder.insert(%{"type" => "Announce", "context" => "2hu"})
activities = ActivityPub.fetch_activities_for_context("2hu")
- assert activities == [activity, activity_two]
+ assert activities == [activity_two, activity]
end
end
follower = Repo.get_by(User, ap_id: activity.data["actor"])
followed = Repo.get_by(User, ap_id: activity.data["object"])
- assert activity == ActivityPub.fetch_latest_follow(follower, followed)
+ assert activity == Utils.fetch_latest_follow(follower, followed)
end
end