2020-02-18 08:57:00 +01:00
|
|
|
defmodule Mobilizon.Federation.ActivityPub.RefresherTest do
|
|
|
|
use Mobilizon.DataCase
|
|
|
|
|
|
|
|
alias Mobilizon.Actors.{Actor, Member}
|
|
|
|
alias Mobilizon.Federation.ActivityPub.Refresher
|
2020-07-09 17:24:28 +02:00
|
|
|
alias Mobilizon.Service.HTTP.ActivityPub.Mock
|
2020-02-18 08:57:00 +01:00
|
|
|
alias Mobilizon.Web.ActivityPub.ActorView
|
|
|
|
import Mobilizon.Factory
|
2020-07-09 17:24:28 +02:00
|
|
|
import Mox
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-07-09 17:24:28 +02:00
|
|
|
describe "refreshes a" do
|
|
|
|
setup :verify_on_exit!
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-07-09 17:24:28 +02:00
|
|
|
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)
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
assert :ok == Refresher.fetch_collection(group.members_url, actor)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|