def superuser?(%User{local: true, info: %User.Info{is_moderator: true}}), do: true
def superuser?(_), do: false
+ def invisible?(%User{info: %User.Info{invisible: true}}), do: true
+ def invisible?(_), do: false
+
def avatar_url(user, options \\ []) do
case user.avatar do
%{"url" => [%{"href" => href} | _]} -> href
end
end
+ describe "invisible?/1" do
+ test "returns true for an invisible user" do
+ user = insert(:user, local: true, info: %{invisible: true})
+
+ assert User.invisible?(user)
+ end
+
+ test "returns false for a non-invisible user" do
+ user = insert(:user, local: true)
+
+ refute User.invisible?(user)
+ end
+ end
+
describe "visible_for?/2" do
test "returns true when the account is itself" do
user = insert(:user, local: true)