diff options
| author | rinpatch <rinpatch@sdf.org> | 2020-05-04 15:47:04 +0000 |
|---|---|---|
| committer | rinpatch <rinpatch@sdf.org> | 2020-05-04 15:47:04 +0000 |
| commit | 378ab2db97843112523985ca72b427702d50fe58 (patch) | |
| tree | de1528772ec6cb9978272d0fbd71c6b7430d4e52 /test/web/activity_pub/object_validator_test.exs | |
| parent | 095635453ac58b9e01a32ad226c0b61466c16da0 (diff) | |
| parent | 3559dd108518dfa740878cecdc86c0357b265857 (diff) | |
| download | pleroma-378ab2db97843112523985ca72b427702d50fe58.tar.gz pleroma-378ab2db97843112523985ca72b427702d50fe58.zip | |
Merge branch 'feature/favorite-refactor' into 'develop'
Like activities: Move fixes to validator.
See merge request pleroma/pleroma!2467
Diffstat (limited to 'test/web/activity_pub/object_validator_test.exs')
| -rw-r--r-- | test/web/activity_pub/object_validator_test.exs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs index 3c5c3696e..93989e28a 100644 --- a/test/web/activity_pub/object_validator_test.exs +++ b/test/web/activity_pub/object_validator_test.exs @@ -36,6 +36,32 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do assert LikeValidator.cast_and_validate(valid_like).valid? end + test "sets the 'to' field to the object actor if no recipients are given", %{ + valid_like: valid_like, + user: user + } do + without_recipients = + valid_like + |> Map.delete("to") + + {:ok, object, _meta} = ObjectValidator.validate(without_recipients, []) + + assert object["to"] == [user.ap_id] + end + + test "sets the context field to the context of the object if no context is given", %{ + valid_like: valid_like, + post_activity: post_activity + } do + without_context = + valid_like + |> Map.delete("context") + + {:ok, object, _meta} = ObjectValidator.validate(without_context, []) + + assert object["context"] == post_activity.data["context"] + end + test "it errors when the actor is missing or not known", %{valid_like: valid_like} do without_actor = Map.delete(valid_like, "actor") |
