import ExUnit.CaptureLog
import Pleroma.Factory
import Tesla.Mock
+ import Mock
alias Pleroma.Signature
"https://example.com/users/1234"
end
end
+
+ describe "signed_date" do
+ test "it returns formatted current date" do
+ with_mock(NaiveDateTime, utc_now: fn -> ~N[2019-08-23 18:11:24.822233] end) do
+ assert Signature.signed_date() == "Fri, 23 Aug 2019 18:11:24 GMT"
+ end
+ end
+
+ test "it returns formatted date" do
+ assert Signature.signed_date(~N[2019-08-23 08:11:24.822233]) ==
+ "Fri, 23 Aug 2019 08:11:24 GMT"
+ end
+ end
end
%User{ap_id: follower_id} = local_user = Relay.get_actor()
target_user = User.get_cached_by_ap_id(target_instance)
follow_activity = Utils.fetch_latest_follow(local_user, target_user)
-
+ User.follow(local_user, target_user)
+ assert "#{target_instance}/followers" in refresh_record(local_user).following
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
cancelled_activity = Activity.get_by_ap_id(follow_activity.data["id"])
assert undo_activity.data["type"] == "Undo"
assert undo_activity.data["actor"] == local_user.ap_id
assert undo_activity.data["object"] == cancelled_activity.data
+ refute "#{target_instance}/followers" in refresh_record(local_user).following
end
end
user = insert(:user)
service_actor = Relay.get_actor()
ActivityPub.follow(service_actor, user)
+ Pleroma.User.follow(service_actor, user)
+ assert "#{user.ap_id}/followers" in refresh_record(service_actor).following
assert {:ok, %Activity{} = activity} = Relay.unfollow(user.ap_id)
assert activity.actor == "#{Pleroma.Web.Endpoint.url()}/relay"
assert user.ap_id in activity.recipients
assert activity.data["type"] == "Undo"
assert activity.data["actor"] == service_actor.ap_id
assert activity.data["to"] == [user.ap_id]
+ refute "#{user.ap_id}/followers" in refresh_record(service_actor).following
end
end