diff options
author | Maksim <parallel588@gmail.com> | 2019-07-24 15:13:10 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-07-24 15:13:10 +0000 |
commit | 55341ac71740d3d8aded9c6520e06b9c509a6670 (patch) | |
tree | b03dc535780fdd459ed71dc9b1d1d70fdf79beff /test/plugs/set_format_plug_test.exs | |
parent | b7fae304d31b974c1580b8df73d7e52cd2b79846 (diff) | |
download | pleroma-55341ac71740d3d8aded9c6520e06b9c509a6670.tar.gz pleroma-55341ac71740d3d8aded9c6520e06b9c509a6670.zip |
tests WebFinger
Diffstat (limited to 'test/plugs/set_format_plug_test.exs')
-rw-r--r-- | test/plugs/set_format_plug_test.exs | 38 |
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 |