Merge branch 'exclude-reblogs-from-admin-api-by-default' into 'develop'
[akkoma] / test / plugs / set_format_plug_test.exs
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
5 defmodule Pleroma.Plugs.SetFormatPlugTest do
6 use ExUnit.Case, async: true
7 use Plug.Test
8
9 alias Pleroma.Plugs.SetFormatPlug
10
11 test "set format from params" do
12 conn =
13 :get
14 |> conn("/cofe?_format=json")
15 |> SetFormatPlug.call([])
16
17 assert %{format: "json"} == conn.assigns
18 end
19
20 test "set format from header" do
21 conn =
22 :get
23 |> conn("/cofe")
24 |> put_private(:phoenix_format, "xml")
25 |> SetFormatPlug.call([])
26
27 assert %{format: "xml"} == conn.assigns
28 end
29
30 test "doesn't set format" do
31 conn =
32 :get
33 |> conn("/cofe")
34 |> SetFormatPlug.call([])
35
36 refute conn.assigns[:format]
37 end
38 end