Web.RelMe: Fix having other values in rel attr
[akkoma] / test / support / factory.ex
index 7a91549f5eb687c591035879edf2c7c173c10ba6..c025aaf21326a105d9e6ef5bb55caad0215ad21b 100644 (file)
@@ -23,7 +23,7 @@ defmodule Pleroma.Factory do
     }
   end
 
-  def note_factory do
+  def note_factory(attrs \\ %{}) do
     text = sequence(:text, &"This is :moominmamma: note #{&1}")
 
     user = insert(:user)
@@ -46,7 +46,7 @@ defmodule Pleroma.Factory do
     }
 
     %Pleroma.Object{
-      data: data
+      data: merge_attributes(data, Map.get(attrs, :data, %{}))
     }
   end
 
@@ -95,8 +95,8 @@ defmodule Pleroma.Factory do
     }
   end
 
-  def note_activity_factory do
-    note = insert(:note)
+  def note_activity_factory(attrs \\ %{}) do
+    note = attrs[:note] || insert(:note)
 
     data = %{
       "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
@@ -135,9 +135,9 @@ defmodule Pleroma.Factory do
     }
   end
 
-  def announce_activity_factory do
-    note_activity = insert(:note_activity)
-    user = insert(:user)
+  def announce_activity_factory(attrs \\ %{}) do
+    note_activity = attrs[:note_activity] || insert(:note_activity)
+    user = attrs[:user] || insert(:user)
 
     data = %{
       "type" => "Announce",
@@ -214,7 +214,7 @@ defmodule Pleroma.Factory do
     %Pleroma.Web.OAuth.App{
       client_name: "Some client",
       redirect_uris: "https://example.com/callback",
-      scopes: "read",
+      scopes: ["read", "write", "follow", "push"],
       website: "https://example.com",
       client_id: "aaabbb==",
       client_secret: "aaa;/&bbb"