+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.UserTest do
alias Pleroma.Builders.UserBuilder
alias Pleroma.{User, Repo, Activity}
:ok
end
+ describe "when tags are nil" do
+ test "tagging a user" do
+ user = insert(:user, %{tags: nil})
+ user = User.tag(user, ["cool", "dude"])
+
+ assert "cool" in user.tags
+ assert "dude" in user.tags
+ end
+
+ test "untagging a user" do
+ user = insert(:user, %{tags: nil})
+ user = User.untag(user, ["cool", "dude"])
+
+ assert user.tags == []
+ end
+ end
+
test "ap_id returns the activity pub id for the user" do
user = UserBuilder.build()
end
end
+ describe "user registration, with :account_activation_required" do
+ @full_user_data %{
+ bio: "A guy",
+ name: "my name",
+ nickname: "nick",
+ password: "test",
+ password_confirmation: "test",
+ email: "email@example.com"
+ }
+
+ setup do
+ setting = Pleroma.Config.get([:instance, :account_activation_required])
+
+ unless setting do
+ Pleroma.Config.put([:instance, :account_activation_required], true)
+ on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end)
+ end
+
+ :ok
+ end
+
+ test "it creates unconfirmed user" do
+ changeset = User.register_changeset(%User{}, @full_user_data)
+ assert changeset.valid?
+
+ {:ok, user} = Repo.insert(changeset)
+
+ assert user.info.confirmation_pending
+ assert user.info.confirmation_token
+ end
+
+ test "it creates confirmed user if :confirmed option is given" do
+ changeset = User.register_changeset(%User{}, @full_user_data, confirmed: true)
+ assert changeset.valid?
+
+ {:ok, user} = Repo.insert(changeset)
+
+ refute user.info.confirmation_pending
+ refute user.info.confirmation_token
+ end
+ end
+
describe "get_or_fetch/1" do
test "gets an existing user by nickname" do
user = insert(:user)