test: user: add tests for visible_for?/2
This commit is contained in:
parent
f2a4f89abe
commit
567651fb3f
@ -809,4 +809,41 @@ test "returns true for local admins" do
|
|||||||
assert User.superuser?(user)
|
assert User.superuser?(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "visible_for?/2" do
|
||||||
|
test "returns true when the account is itself" do
|
||||||
|
user = insert(:user, local: true)
|
||||||
|
|
||||||
|
assert User.visible_for?(user, user)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "returns false when the account is unauthenticated and auth is required" do
|
||||||
|
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
|
user = insert(:user, local: true, info: %{confirmation_pending: true})
|
||||||
|
other_user = insert(:user, local: true)
|
||||||
|
|
||||||
|
refute User.visible_for?(user, other_user)
|
||||||
|
|
||||||
|
Pleroma.Config.put([:instance, :account_activation_required], false)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "returns true when the account is unauthenticated and auth is not required" do
|
||||||
|
user = insert(:user, local: true, info: %{confirmation_pending: true})
|
||||||
|
other_user = insert(:user, local: true)
|
||||||
|
|
||||||
|
assert User.visible_for?(user, other_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "returns true when the account is unauthenticated and being viewed by a privileged account (auth required)" do
|
||||||
|
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
|
user = insert(:user, local: true, info: %{confirmation_pending: true})
|
||||||
|
other_user = insert(:user, local: true, info: %{is_admin: true})
|
||||||
|
|
||||||
|
assert User.visible_for?(user, other_user)
|
||||||
|
|
||||||
|
Pleroma.Config.put([:instance, :account_activation_required], false)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user