user_enabled_plug_test.exs 841 Bytes
Newer Older
lain's avatar
lain committed
1
2
3
defmodule Pleroma.Plugs.UserEnabledPlugTest do
  use Pleroma.Web.ConnCase, async: true

4
  alias Pleroma.Plugs.UserEnabledPlug
5
  import Pleroma.Factory
lain's avatar
lain committed
6
7
8
9
10
11
12
13
14
15

  test "doesn't do anything if the user isn't set", %{conn: conn} do
    ret_conn =
      conn
      |> UserEnabledPlug.call(%{})

    assert ret_conn == conn
  end

  test "with a user that is deactivated, it removes that user", %{conn: conn} do
lain's avatar
lain committed
16
    user = insert(:user, info: %{deactivated: true})
17

lain's avatar
lain committed
18
19
    conn =
      conn
20
      |> assign(:user, user)
lain's avatar
lain committed
21
22
23
24
25
26
      |> UserEnabledPlug.call(%{})

    assert conn.assigns.user == nil
  end

  test "with a user that is not deactivated, it does nothing", %{conn: conn} do
27
28
    user = insert(:user)

lain's avatar
lain committed
29
30
    conn =
      conn
31
      |> assign(:user, user)
lain's avatar
lain committed
32
33
34
35
36
37
38
39

    ret_conn =
      conn
      |> UserEnabledPlug.call(%{})

    assert conn == ret_conn
  end
end