mobilizon.chapril.org-mobil.../test/federation/activity_pub/refresher_test.exs
Thomas Citharel 9c9f1385fb
Introduce group posts
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-07-30 16:55:35 +02:00

38 lines
1.1 KiB
Elixir

defmodule Mobilizon.Federation.ActivityPub.RefresherTest do
use Mobilizon.DataCase
alias Mobilizon.Actors.{Actor, Member}
alias Mobilizon.Federation.ActivityPub.Refresher
alias Mobilizon.Service.HTTP.ActivityPub.Mock
alias Mobilizon.Web.ActivityPub.ActorView
import Mobilizon.Factory
import Mox
describe "refreshes a" do
setup :verify_on_exit!
test "members collection" do
%Actor{members_url: members_url} =
group =
insert(:group,
url: "https://remoteinstance.tld/@group",
members_url: "https://remoteinstance.tld/@group/members",
domain: "remoteinstance.tld"
)
%Actor{} = actor = insert(:actor)
%Member{} = insert(:member, parent: group, actor: actor, role: :member)
data = ActorView.render("members.json", %{actor: group, actor_applicant: actor})
Mock
|> expect(:call, fn
%{method: :get, url: ^members_url}, _opts ->
{:ok, %Tesla.Env{status: 200, body: data}}
end)
assert :ok == Refresher.fetch_collection(group.members_url, actor)
end
end
end