summaryrefslogtreecommitdiff
path: root/test/plugs/set_format_plug_test.exs
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-07-25 18:43:30 +0300
committerrinpatch <rinpatch@sdf.org>2019-07-25 18:43:30 +0300
commit41e0304757c5a0d9778f7e685c9ddf481f0e15cb (patch)
treedc60d86d41153d9764cb32a9adae5fa24894c1fa /test/plugs/set_format_plug_test.exs
parent196cad46f35a63c18d58cd5d982bc4e1f9b0d7c3 (diff)
parentd1e891062e3c6c34ca7940a476917beea2822ca2 (diff)
downloadpleroma-41e0304757c5a0d9778f7e685c9ddf481f0e15cb.tar.gz
pleroma-41e0304757c5a0d9778f7e685c9ddf481f0e15cb.zip
Merge branch 'develop' into feature/hide-follows-remote
Diffstat (limited to 'test/plugs/set_format_plug_test.exs')
-rw-r--r--test/plugs/set_format_plug_test.exs38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/plugs/set_format_plug_test.exs b/test/plugs/set_format_plug_test.exs
new file mode 100644
index 000000000..bb21956bb
--- /dev/null
+++ b/test/plugs/set_format_plug_test.exs
@@ -0,0 +1,38 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Plugs.SetFormatPlugTest do
+ use ExUnit.Case, async: true
+ use Plug.Test
+
+ alias Pleroma.Plugs.SetFormatPlug
+
+ test "set format from params" do
+ conn =
+ :get
+ |> conn("/cofe?_format=json")
+ |> SetFormatPlug.call([])
+
+ assert %{format: "json"} == conn.assigns
+ end
+
+ test "set format from header" do
+ conn =
+ :get
+ |> conn("/cofe")
+ |> put_private(:phoenix_format, "xml")
+ |> SetFormatPlug.call([])
+
+ assert %{format: "xml"} == conn.assigns
+ end
+
+ test "doesn't set format" do
+ conn =
+ :get
+ |> conn("/cofe")
+ |> SetFormatPlug.call([])
+
+ refute conn.assigns[:format]
+ end
+end