diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-04-22 13:08:30 +0700 |
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-04-22 13:08:30 +0700 |
| commit | e8c2f9a73a37636a9a8ed5c2998617b841f482da (patch) | |
| tree | 4b194e631d2bbb58b8522c3d74a0b0c2ea09fedd /test/object_test.exs | |
| parent | 38926a063a39c4d4387049f5d364f72a9f8bd2de (diff) | |
| parent | 7fcbda702e76b6390076c28832f5aea80086d15a (diff) | |
| download | pleroma-e8c2f9a73a37636a9a8ed5c2998617b841f482da.tar.gz pleroma-e8c2f9a73a37636a9a8ed5c2998617b841f482da.zip | |
Merge remote-tracking branch 'pleroma/develop' into feature/disable-account
Diffstat (limited to 'test/object_test.exs')
| -rw-r--r-- | test/object_test.exs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/object_test.exs b/test/object_test.exs index 911757d57..d138ee091 100644 --- a/test/object_test.exs +++ b/test/object_test.exs @@ -5,9 +5,15 @@ defmodule Pleroma.ObjectTest do use Pleroma.DataCase import Pleroma.Factory + import Tesla.Mock alias Pleroma.Object alias Pleroma.Repo + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end + test "returns an object by it's AP id" do object = insert(:note) found_object = Object.get_by_ap_id(object.data["id"]) @@ -58,4 +64,26 @@ defmodule Pleroma.ObjectTest do assert cached_object.data["type"] == "Tombstone" end end + + describe "normalizer" do + test "fetches unknown objects by default" do + %Object{} = + object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367") + + assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367" + end + + test "fetches unknown objects when fetch_remote is explicitly true" do + %Object{} = + object = Object.normalize("http://mastodon.example.org/@admin/99541947525187367", true) + + assert object.data["url"] == "http://mastodon.example.org/@admin/99541947525187367" + end + + test "does not fetch unknown objects when fetch_remote is false" do + assert is_nil( + Object.normalize("http://mastodon.example.org/@admin/99541947525187367", false) + ) + end + end end |
