logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

ensure_user_key_plug_test.exs (701B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Plugs.EnsureUserKeyPlugTest do
  5. use Pleroma.Web.ConnCase, async: true
  6. alias Pleroma.Plugs.EnsureUserKeyPlug
  7. test "if the conn has a user key set, it does nothing", %{conn: conn} do
  8. conn =
  9. conn
  10. |> assign(:user, 1)
  11. ret_conn =
  12. conn
  13. |> EnsureUserKeyPlug.call(%{})
  14. assert conn == ret_conn
  15. end
  16. test "if the conn has no key set, it sets it to nil", %{conn: conn} do
  17. conn =
  18. conn
  19. |> EnsureUserKeyPlug.call(%{})
  20. assert Map.has_key?(conn.assigns, :user)
  21. end
  22. end