diff options
| author | William Pitcock <nenolod@dereferenced.org> | 2019-01-09 07:03:32 +0000 | 
|---|---|---|
| committer | William Pitcock <nenolod@dereferenced.org> | 2019-01-09 07:03:32 +0000 | 
| commit | 567651fb3fcacbe5bb2f9c19deb9655edaaad076 (patch) | |
| tree | dd0fa1c679829b023e076b3df77e63fb3b68ee05 /test | |
| parent | f2a4f89abef810f1106afa3a9ef82fa748bc783e (diff) | |
| download | pleroma-567651fb3fcacbe5bb2f9c19deb9655edaaad076.tar.gz pleroma-567651fb3fcacbe5bb2f9c19deb9655edaaad076.zip | |
test: user: add tests for visible_for?/2
Diffstat (limited to 'test')
| -rw-r--r-- | test/user_test.exs | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/test/user_test.exs b/test/user_test.exs index 582374fb9..542eaaaeb 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -809,4 +809,41 @@ defmodule Pleroma.UserTest do        assert User.superuser?(user)      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 | 
