X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fmastodon_api%2Fviews%2Faccount_view_test.exs;h=c23ffb966d38d0ce99f9679c147a16e0adda0d14;hb=de006443f0bc8cfb3ad28b29b2d8ea9581e760b6;hp=f4e6c161ec21ee389efc5bdf759d1aabb4837c5b;hpb=958a7f6ed071a5bfd0ea92c602fe0ee876c1e4c6;p=akkoma diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index f4e6c161e..c23ffb966 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.User alias Pleroma.UserRelationship alias Pleroma.Web.CommonAPI @@ -74,6 +73,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do }, fields: [] }, + fqn: "shp@shitposter.club", + last_status_at: nil, pleroma: %{ ap_id: user.ap_id, also_known_as: ["https://shitposter.zone/users/shp"], @@ -83,6 +84,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do tags: [], is_admin: false, is_moderator: false, + is_suggested: false, hide_favorites: true, hide_followers: false, hide_follows: false, @@ -173,6 +175,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do }, fields: [] }, + fqn: "shp@shitposter.club", + last_status_at: nil, pleroma: %{ ap_id: user.ap_id, also_known_as: [], @@ -182,6 +186,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do tags: [], is_admin: false, is_moderator: false, + is_suggested: false, hide_favorites: true, hide_followers: false, hide_follows: false, @@ -211,7 +216,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do test "Represent a deactivated user for an admin" do admin = insert(:user, is_admin: true) - deactivated_user = insert(:user, deactivated: true) + deactivated_user = insert(:user, is_active: false) represented = AccountView.render("show.json", %{user: deactivated_user, for: admin}) assert represented[:pleroma][:deactivated] == true end @@ -267,10 +272,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do muting: false, muting_notifications: false, subscribing: false, + notifying: false, requested: false, domain_blocking: false, showing_reblogs: true, - endorsed: false + endorsed: false, + note: "" } test "represent a relationship for the following and followed user" do @@ -292,6 +299,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do muting: true, muting_notifications: true, subscribing: true, + notifying: true, showing_reblogs: false, id: to_string(other_user.id) } @@ -467,6 +475,23 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do %{user: user, for: user} )[:pleroma][:unread_notifications_count] == 7 end + + test "shows email only to the account owner" do + user = insert(:user) + other_user = insert(:user) + + user = User.get_cached_by_ap_id(user.ap_id) + + assert AccountView.render( + "show.json", + %{user: user, for: other_user} + )[:pleroma][:email] == nil + + assert AccountView.render( + "show.json", + %{user: user, for: user} + )[:pleroma][:email] == user.email + end end describe "follow requests counter" do @@ -556,17 +581,17 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do ) with media_preview_enabled <- [false, true] do - Config.put([:media_preview_proxy, :enabled], media_preview_enabled) + clear_config([:media_preview_proxy, :enabled], media_preview_enabled) AccountView.render("show.json", %{user: user, skip_visibility_check: true}) |> Enum.all?(fn {key, url} when key in [:avatar, :avatar_static, :header, :header_static] -> - String.starts_with?(url, Pleroma.Web.base_url()) + String.starts_with?(url, Pleroma.Web.Endpoint.url()) {:emojis, emojis} -> Enum.all?(emojis, fn %{url: url, static_url: static_url} -> - String.starts_with?(url, Pleroma.Web.base_url()) && - String.starts_with?(static_url, Pleroma.Web.base_url()) + String.starts_with?(url, Pleroma.Web.Endpoint.url()) && + String.starts_with?(static_url, Pleroma.Web.Endpoint.url()) end) _ ->