diff options
author | lain <lain@soykaf.club> | 2020-05-13 15:31:28 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-13 15:31:28 +0200 |
commit | 0f0acc740d30c47d093f27875d4decf0693b2845 (patch) | |
tree | 0cdc813d983f535898c515d4a87a503bb7d3acd1 /test/web/pleroma_api/controllers/chat_controller_test.exs | |
parent | 06cad239e50cada3aec4fc3b4c494a70d328672c (diff) | |
download | pleroma-0f0acc740d30c47d093f27875d4decf0693b2845.tar.gz pleroma-0f0acc740d30c47d093f27875d4decf0693b2845.zip |
Chat: Allow posting without content if an attachment is present.
Diffstat (limited to 'test/web/pleroma_api/controllers/chat_controller_test.exs')
-rw-r--r-- | test/web/pleroma_api/controllers/chat_controller_test.exs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/web/pleroma_api/controllers/chat_controller_test.exs b/test/web/pleroma_api/controllers/chat_controller_test.exs index 037dd2297..d79aa3148 100644 --- a/test/web/pleroma_api/controllers/chat_controller_test.exs +++ b/test/web/pleroma_api/controllers/chat_controller_test.exs @@ -53,6 +53,20 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do assert result["chat_id"] == chat.id |> to_string() end + test "it fails if there is no content", %{conn: conn, user: user} do + other_user = insert(:user) + + {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id) + + result = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/pleroma/chats/#{chat.id}/messages") + |> json_response_and_validate_schema(400) + + assert result + end + test "it works with an attachment", %{conn: conn, user: user} do file = %Plug.Upload{ content_type: "image/jpg", @@ -70,13 +84,11 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do conn |> put_req_header("content-type", "application/json") |> post("/api/v1/pleroma/chats/#{chat.id}/messages", %{ - "content" => "Hallo!!", "media_id" => to_string(upload.id) }) |> json_response_and_validate_schema(200) - assert result["content"] == "Hallo!!" - assert result["chat_id"] == chat.id |> to_string() + assert result["attachment"] end end |