Add test for POST when push is disabled
Also group together the tests verifiying failure when disabled
This commit is contained in:
parent
3eaa5335c9
commit
415481a4d9
|
@ -45,15 +45,44 @@ defmacro assert_error_when_disable_push(do: yield) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "creates push subscription" do
|
describe "when disabled" do
|
||||||
test "does not return unsupported types", %{conn: conn} do
|
test "POST returns error", %{conn: conn} do
|
||||||
assert_error_when_disable_push do
|
assert_error_when_disable_push do
|
||||||
conn
|
conn
|
||||||
|> post("/api/v1/push/subscription", %{subscription: @sub})
|
|> post("/api/v1/push/subscription", %{
|
||||||
|
"data" => %{"alerts" => %{"mention" => true}},
|
||||||
|
"subscription" => @sub
|
||||||
|
})
|
||||||
|> json_response_and_validate_schema(403)
|
|> json_response_and_validate_schema(403)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "GET returns error", %{conn: conn} do
|
||||||
|
assert_error_when_disable_push do
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/push/subscription", %{})
|
||||||
|
|> json_response_and_validate_schema(403)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "PUT returns error", %{conn: conn} do
|
||||||
|
assert_error_when_disable_push do
|
||||||
|
conn
|
||||||
|
|> put("/api/v1/push/subscription", %{data: %{"alerts" => %{"mention" => false}}})
|
||||||
|
|> json_response_and_validate_schema(403)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "DELETE returns error", %{conn: conn} do
|
||||||
|
assert_error_when_disable_push do
|
||||||
|
conn
|
||||||
|
|> delete("/api/v1/push/subscription", %{})
|
||||||
|
|> json_response_and_validate_schema(403)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "creates push subscription" do
|
||||||
test "ignores unsupported types", %{conn: conn} do
|
test "ignores unsupported types", %{conn: conn} do
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
@ -111,14 +140,6 @@ test "successful creation", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "gets a user subscription" do
|
describe "gets a user subscription" do
|
||||||
test "returns error when push disabled ", %{conn: conn} do
|
|
||||||
assert_error_when_disable_push do
|
|
||||||
conn
|
|
||||||
|> get("/api/v1/push/subscription", %{})
|
|
||||||
|> json_response_and_validate_schema(403)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns error when user hasn't subscription", %{conn: conn} do
|
test "returns error when user hasn't subscription", %{conn: conn} do
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
|
@ -173,14 +194,6 @@ test "returns a user subsciption", %{conn: conn, user: user, token: token} do
|
||||||
%{conn: conn, user: user, token: token, subscription: subscription}
|
%{conn: conn, user: user, token: token, subscription: subscription}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns error when push disabled ", %{conn: conn} do
|
|
||||||
assert_error_when_disable_push do
|
|
||||||
conn
|
|
||||||
|> put("/api/v1/push/subscription", %{data: %{"alerts" => %{"mention" => false}}})
|
|
||||||
|> json_response_and_validate_schema(403)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns updated subsciption", %{conn: conn, subscription: subscription} do
|
test "returns updated subsciption", %{conn: conn, subscription: subscription} do
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
|
@ -217,14 +230,6 @@ test "returns updated subsciption", %{conn: conn, subscription: subscription} do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "deletes the user subscription" do
|
describe "deletes the user subscription" do
|
||||||
test "returns error when push disabled ", %{conn: conn} do
|
|
||||||
assert_error_when_disable_push do
|
|
||||||
conn
|
|
||||||
|> delete("/api/v1/push/subscription", %{})
|
|
||||||
|> json_response_and_validate_schema(403)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns error when user hasn't subscription", %{conn: conn} do
|
test "returns error when user hasn't subscription", %{conn: conn} do
|
||||||
res =
|
res =
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in a new issue