summaryrefslogtreecommitdiff
path: root/test/support/factory.ex
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-08-08 14:41:28 -0400
committerMark Felder <feld@feld.me>2024-08-12 17:12:39 -0400
commitc0ca7a4ecab76607227221fa96df1ccb9313131e (patch)
treed4660516d2db5c54fd2250adab66dcb37d5ab287 /test/support/factory.ex
parentc29441f30d0229192868ec4149a46fea562b0997 (diff)
downloadpleroma-c0ca7a4ecab76607227221fa96df1ccb9313131e.tar.gz
pleroma-c0ca7a4ecab76607227221fa96df1ccb9313131e.zip
User Factory: include the nickname in the generated URLs
Diffstat (limited to 'test/support/factory.ex')
-rw-r--r--test/support/factory.ex32
1 files changed, 17 insertions, 15 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex
index fb26f4162..8f1c6faf9 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -53,6 +53,13 @@ defmodule Pleroma.Factory do
keys: pem
}
+ user
+ |> Map.put(:raw_bio, user.bio)
+ |> merge_attributes(Map.delete(attrs, :domain))
+ |> make_user_urls(attrs)
+ end
+
+ defp make_user_urls(user, attrs) do
urls =
if attrs[:local] == false do
base_domain = attrs[:domain] || Enum.random(["domain1.com", "domain2.com", "domain3.com"])
@@ -60,27 +67,22 @@ defmodule Pleroma.Factory do
ap_id = "https://#{base_domain}/users/#{user.nickname}"
%{
- ap_id: ap_id,
- follower_address: ap_id <> "/followers",
- following_address: ap_id <> "/following",
- featured_address: ap_id <> "/collections/featured",
- inbox: "https://#{base_domain}/inbox"
+ ap_id: attrs[:ap_id] || ap_id,
+ follower_address: attrs[:follower_address] || ap_id <> "/followers",
+ following_address: attrs[:following_address] || ap_id <> "/following",
+ featured_address: attrs[:featured_address] || ap_id <> "/collections/featured",
+ inbox: attrs[:inbox] || "https://#{base_domain}/inbox"
}
else
%{
- ap_id: User.ap_id(user),
- follower_address: User.ap_followers(user),
- following_address: User.ap_following(user),
- featured_address: User.ap_featured_collection(user)
+ ap_id: attrs[:ap_id] || User.ap_id(user),
+ follower_address: attrs[:follower_address] || User.ap_followers(user),
+ following_address: attrs[:following_address] || User.ap_following(user),
+ featured_address: attrs[:featured_address] || User.ap_featured_collection(user)
}
end
- attrs = Map.delete(attrs, :domain)
-
- user
- |> Map.put(:raw_bio, user.bio)
- |> Map.merge(urls)
- |> merge_attributes(attrs)
+ Map.merge(user, urls)
end
def user_relationship_factory(attrs \\ %{}) do