Fix tests
This commit is contained in:
parent
f86bf16430
commit
cc63a89b5d
|
@ -346,12 +346,17 @@ def fix_tag(%{"tag" => %{} = tag} = object) do
|
||||||
def fix_tag(object), do: object
|
def fix_tag(object), do: object
|
||||||
|
|
||||||
# content map usually only has one language so this will do for now.
|
# content map usually only has one language so this will do for now.
|
||||||
def fix_content_map(%{"contentMap" => content_map} = object) do
|
def fix_content_map(%{"contentMap" => content_map} = object) when is_map(content_map) do
|
||||||
content_groups = Map.to_list(content_map)
|
content_groups = Map.to_list(content_map)
|
||||||
|
|
||||||
|
if Enum.empty?(content_groups) do
|
||||||
|
object
|
||||||
|
else
|
||||||
{_, content} = Enum.at(content_groups, 0)
|
{_, content} = Enum.at(content_groups, 0)
|
||||||
|
|
||||||
Map.put(object, "content", content)
|
Map.put(object, "content", content)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def fix_content_map(object), do: object
|
def fix_content_map(object), do: object
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,18 @@ test "posting an undefined status with an attachment", %{user: user, conn: conn}
|
||||||
assert json_response_and_validate_schema(conn, 200)
|
assert json_response_and_validate_schema(conn, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "posting a status with an invalid language", %{conn: conn} do
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/v1/statuses", %{
|
||||||
|
"status" => "cofe",
|
||||||
|
"language" => "invalid"
|
||||||
|
})
|
||||||
|
|
||||||
|
assert %{"error" => "Invalid language"} = json_response_and_validate_schema(conn, 422)
|
||||||
|
end
|
||||||
|
|
||||||
test "replying to a status", %{user: user, conn: conn} do
|
test "replying to a status", %{user: user, conn: conn} do
|
||||||
{:ok, replied_to} = CommonAPI.post(user, %{status: "cofe"})
|
{:ok, replied_to} = CommonAPI.post(user, %{status: "cofe"})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue