Merge branch 'remove-swift' into 'develop'
[akkoma] / test / web / ostatus / ostatus_controller_test.exs
index 2950f11c0c2f8dd915d9ef424480e32367423665..eae44dba5125e734841e96a8f0f865d369c58a74 100644 (file)
@@ -6,13 +6,19 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
   use Pleroma.Web.ConnCase
   import Pleroma.Factory
   alias Pleroma.Object
-  alias Pleroma.Repo
   alias Pleroma.User
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.OStatus.ActivityRepresenter
 
   setup_all do
     Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+
+    config_path = [:instance, :federating]
+    initial_setting = Pleroma.Config.get(config_path)
+
+    Pleroma.Config.put(config_path, true)
+    on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
+
     :ok
   end
 
@@ -41,7 +47,8 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
       assert response(conn, 200)
 
       # Set a wrong magic-key for a user so it has to refetch
-      salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
+      salmon_user = User.get_cached_by_ap_id("http://gs.example.org:4040/index.php/user/1")
+
       # Wrong key
       info_cng =
         User.Info.remote_user_creation(salmon_user.info, %{
@@ -52,7 +59,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
       salmon_user
       |> Ecto.Changeset.change()
       |> Ecto.Changeset.put_embed(:info, info_cng)
-      |> Repo.update()
+      |> User.update_and_set_cache()
 
       conn =
         build_conn()
@@ -86,7 +93,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
 
   test "gets an object", %{conn: conn} do
     note_activity = insert(:note_activity)
-    user = User.get_by_ap_id(note_activity.data["actor"])
+    user = User.get_cached_by_ap_id(note_activity.data["actor"])
     [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"]))
     url = "/objects/#{uuid}"