logo

pleroma

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

set_format_plug_test.exs (828B)


  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.SetFormatPlugTest do
  5. use ExUnit.Case, async: true
  6. use Plug.Test
  7. alias Pleroma.Plugs.SetFormatPlug
  8. test "set format from params" do
  9. conn =
  10. :get
  11. |> conn("/cofe?_format=json")
  12. |> SetFormatPlug.call([])
  13. assert %{format: "json"} == conn.assigns
  14. end
  15. test "set format from header" do
  16. conn =
  17. :get
  18. |> conn("/cofe")
  19. |> put_private(:phoenix_format, "xml")
  20. |> SetFormatPlug.call([])
  21. assert %{format: "xml"} == conn.assigns
  22. end
  23. test "doesn't set format" do
  24. conn =
  25. :get
  26. |> conn("/cofe")
  27. |> SetFormatPlug.call([])
  28. refute conn.assigns[:format]
  29. end
  30. end