Fix posts and rework graphql errors
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -64,8 +64,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
variables: %{uuid: "b5126423-f1af-43e4-a923-002a03003ba5"}
|
||||
)
|
||||
|
||||
assert [%{"message" => "Event with UUID b5126423-f1af-43e4-a923-002a03003ba5 not found"}] =
|
||||
res["errors"]
|
||||
assert [%{"message" => "Event not found"}] = res["errors"]
|
||||
end
|
||||
|
||||
@create_event_mutation """
|
||||
@@ -167,7 +166,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] ==
|
||||
"ends_on cannot be set before begins_on"
|
||||
["ends_on cannot be set before begins_on"]
|
||||
end
|
||||
|
||||
test "create_event/3 creates an event", %{conn: conn, actor: actor, user: user} do
|
||||
@@ -374,7 +373,9 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "must be greater than or equal to %{number}"
|
||||
assert hd(res["errors"])["message"] == %{
|
||||
"maximum_attendee_capacity" => ["must be greater than or equal to %{number}"]
|
||||
}
|
||||
end
|
||||
|
||||
test "create_event/3 creates an event with tags", %{conn: conn, actor: actor, user: user} do
|
||||
@@ -726,7 +727,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"ends_on cannot be set before begins_on"
|
||||
["ends_on cannot be set before begins_on"]
|
||||
end
|
||||
|
||||
test "update_event/3 updates an event", %{conn: conn, actor: actor, user: user} do
|
||||
|
||||
@@ -231,7 +231,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "No such post"
|
||||
assert hd(res["errors"])["message"] == "Post not found"
|
||||
end
|
||||
|
||||
test "get_post/3 for an unlisted post", %{
|
||||
@@ -383,7 +383,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "No such post"
|
||||
assert hd(res["errors"])["message"] == "Post not found"
|
||||
end
|
||||
|
||||
test "get_post/3 without being connected for an unlisted post still gives the post", %{
|
||||
@@ -420,7 +420,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "No such post"
|
||||
assert hd(res["errors"])["message"] == "Post not found"
|
||||
end
|
||||
|
||||
test "get_post/3 without being a member for a draft post", %{
|
||||
@@ -440,7 +440,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "No such post"
|
||||
assert hd(res["errors"])["message"] == "Post not found"
|
||||
end
|
||||
|
||||
test "get_post/3 without being connected for a draft post", %{
|
||||
@@ -456,7 +456,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "No such post"
|
||||
assert hd(res["errors"])["message"] == "Post not found"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -592,7 +592,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "No such post"
|
||||
assert hd(res["errors"])["message"] == "Post not found"
|
||||
end
|
||||
|
||||
test "delete_post/3 deletes a post not found", %{
|
||||
|
||||
@@ -367,7 +367,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
conn
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == "This email is already used."
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == ["This email is already used."]
|
||||
end
|
||||
|
||||
test "create_user/3 doesn't allow registration when registration is closed", %{conn: conn} do
|
||||
@@ -614,7 +614,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Email doesn't fit required format"
|
||||
["Email doesn't fit required format"]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user