summaryrefslogtreecommitdiff
path: root/test/elixir/test/form_submit_test.exs
blob: 099f395fccb09af4b433a3a7ed45a7572989bc63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defmodule FormSubmitTest do
  use CouchTestCase

  @moduletag :form_submit
  @moduletag kind: :single_node

  @moduledoc """
  Test that form submission is invalid
  This is a port of form_submit.js
  """

  @tag :with_db
  test "form submission gives back invalid content-type", context do
    headers = [
      Referer: "http://127.0.0.1:15984",
      "Content-Type": "application/x-www-form-urlencoded"
    ]

    body = %{}

    %{:body => response_body, :status_code => status_code} =
      Couch.post("/#{context[:db_name]}/baz", headers: headers, body: body)

    %{"error" => error, "reason" => reason} = response_body

    assert status_code == 415
    assert error == "bad_content_type"
    assert reason == "Content-Type must be multipart/form-data"
  end
end