From 37d8728e16e90a5fc565bcf22f69af737d4f26ef Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Thu, 27 Feb 2020 20:33:01 +0100 Subject: Port form_submit.js test to Elixir --- test/elixir/test/form_submit_test.exs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/elixir/test/form_submit_test.exs diff --git a/test/elixir/test/form_submit_test.exs b/test/elixir/test/form_submit_test.exs new file mode 100644 index 000000000..1baf947ac --- /dev/null +++ b/test/elixir/test/form_submit_test.exs @@ -0,0 +1,29 @@ +defmodule FormSubmitTest do + use CouchTestCase + + @moduletag :form_submit + + @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 -- cgit v1.2.1 From 84ecfb3cb32483a6b4884a4118282b5b5eb661be Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Thu, 27 Feb 2020 22:44:55 +0100 Subject: Mark form_submit JS test as ported in README and inside the test itself --- test/elixir/README.md | 2 +- test/javascript/tests/form_submit.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/elixir/README.md b/test/elixir/README.md index 90b2fd601..5aa70bb9b 100644 --- a/test/elixir/README.md +++ b/test/elixir/README.md @@ -48,7 +48,7 @@ X means done, - means partially - [X] Port erlang_views.js - [X] Port etags_head.js - [ ] ~~Port etags_views.js~~ (skipped in js test suite) - - [ ] Port form_submit.js + - [X] Port form_submit.js - [ ] Port http.js - [X] Port invalid_docids.js - [ ] Port jsonp.js diff --git a/test/javascript/tests/form_submit.js b/test/javascript/tests/form_submit.js index 356182e8d..617686543 100644 --- a/test/javascript/tests/form_submit.js +++ b/test/javascript/tests/form_submit.js @@ -12,6 +12,8 @@ // Do some basic tests. couchTests.form_submit = function(debug) { + return console.log('done in test/elixir/test/form_summit_test.exs'); + var db_name = get_random_db_name(); var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}); db.createDb(); -- cgit v1.2.1