summaryrefslogtreecommitdiff
path: root/test/object_test.exs
diff options
context:
space:
mode:
Diffstat (limited to 'test/object_test.exs')
-rw-r--r--test/object_test.exs28
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