tests: add legal boilerplate
[akkoma] / test / plugs / user_enabled_plug_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Plugs.UserEnabledPlugTest do
6 use Pleroma.Web.ConnCase, async: true
7
8 alias Pleroma.Plugs.UserEnabledPlug
9 import Pleroma.Factory
10
11 test "doesn't do anything if the user isn't set", %{conn: conn} do
12 ret_conn =
13 conn
14 |> UserEnabledPlug.call(%{})
15
16 assert ret_conn == conn
17 end
18
19 test "with a user that is deactivated, it removes that user", %{conn: conn} do
20 user = insert(:user, info: %{deactivated: true})
21
22 conn =
23 conn
24 |> assign(:user, user)
25 |> UserEnabledPlug.call(%{})
26
27 assert conn.assigns.user == nil
28 end
29
30 test "with a user that is not deactivated, it does nothing", %{conn: conn} do
31 user = insert(:user)
32
33 conn =
34 conn
35 |> assign(:user, user)
36
37 ret_conn =
38 conn
39 |> UserEnabledPlug.call(%{})
40
41 assert conn == ret_conn
42 end
43 end