Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / test / plugs / ensure_user_key_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.EnsureUserKeyPlugTest do
6 use Pleroma.Web.ConnCase, async: true
7
8 alias Pleroma.Plugs.EnsureUserKeyPlug
9
10 test "if the conn has a user key set, it does nothing", %{conn: conn} do
11 conn =
12 conn
13 |> assign(:user, 1)
14
15 ret_conn =
16 conn
17 |> EnsureUserKeyPlug.call(%{})
18
19 assert conn == ret_conn
20 end
21
22 test "if the conn has no key set, it sets it to nil", %{conn: conn} do
23 conn =
24 conn
25 |> EnsureUserKeyPlug.call(%{})
26
27 assert Map.has_key?(conn.assigns, :user)
28 end
29 end