AccountView: Add test for show_birthday

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-01-25 17:10:40 +01:00
parent c1ae35ff2c
commit ab12a05a43
2 changed files with 35 additions and 3 deletions

View file

@ -297,7 +297,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
skip_thread_containment: user.skip_thread_containment,
background_image: image_url(user.background) |> MediaProxy.url(),
accepts_chat_messages: user.accepts_chat_messages,
favicon: favicon,
favicon: favicon
}
}
|> maybe_put_role(user, opts[:for])

View file

@ -79,7 +79,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
ap_id: user.ap_id,
also_known_as: ["https://shitposter.zone/users/shp"],
background_image: "https://example.com/images/asuka_hospital.png",
birthday: nil,
favicon: nil,
is_confirmed: true,
tags: [],
@ -182,7 +181,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
ap_id: user.ap_id,
also_known_as: [],
background_image: nil,
birthday: nil,
favicon: nil,
is_confirmed: true,
tags: [],
@ -496,6 +494,40 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
end
end
describe "hiding birthday" do
test "doesn't show birthday if hidden" do
user =
insert(:user, %{
birthday: "2001-02-12",
show_birthday: false
})
other_user = insert(:user)
user = User.get_cached_by_ap_id(user.ap_id)
assert AccountView.render(
"show.json",
%{user: user, for: other_user}
)[:birthday] == nil
end
test "shows hidden birthday to the account owner" do
user =
insert(:user, %{
birthday: "2001-02-12",
show_birthday: false
})
user = User.get_cached_by_ap_id(user.ap_id)
assert AccountView.render(
"show.json",
%{user: user, for: user}
)[:birthday] == nil
end
end
describe "follow requests counter" do
test "shows zero when no follow requests are pending" do
user = insert(:user)