Merge branch 'develop' into feature/database-compaction
[akkoma] / test / object_test.exs
index 72194975d7b25405bae21fedb1c7d9e93d0dedda..a30efd48c7791cfca8c3c66040c2579f74188a39 100644 (file)
@@ -5,7 +5,8 @@
 defmodule Pleroma.ObjectTest do
   use Pleroma.DataCase
   import Pleroma.Factory
-  alias Pleroma.{Repo, Object}
+  alias Pleroma.Object
+  alias Pleroma.Repo
 
   test "returns an object by it's AP id" do
     object = insert(:note)
@@ -57,4 +58,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