diff options
author | lain <lain@soykaf.club> | 2020-04-24 16:10:43 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-04-24 16:10:43 +0000 |
commit | d862c7156a1edcdc89425143901f140bc0b1f5eb (patch) | |
tree | e5f3e28956e01930ff4c21ac982733ef718645d5 /test/web/mastodon_api/controllers/domain_block_controller_test.exs | |
parent | 2430b9bf90d6fde71885f5f0f8be767526be6208 (diff) | |
parent | f362836742aabd5b60b92c1296f2bbb6d83a3d59 (diff) | |
download | pleroma-d862c7156a1edcdc89425143901f140bc0b1f5eb.tar.gz pleroma-d862c7156a1edcdc89425143901f140bc0b1f5eb.zip |
Merge branch 'openapi-improvements' into 'develop'
Support validation for inline OpenAPI schema and automatic tests for examples
Closes #1696
See merge request pleroma/pleroma!2421
Diffstat (limited to 'test/web/mastodon_api/controllers/domain_block_controller_test.exs')
-rw-r--r-- | test/web/mastodon_api/controllers/domain_block_controller_test.exs | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/test/web/mastodon_api/controllers/domain_block_controller_test.exs b/test/web/mastodon_api/controllers/domain_block_controller_test.exs index d66190c90..01a24afcf 100644 --- a/test/web/mastodon_api/controllers/domain_block_controller_test.exs +++ b/test/web/mastodon_api/controllers/domain_block_controller_test.exs @@ -6,11 +6,8 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do use Pleroma.Web.ConnCase alias Pleroma.User - alias Pleroma.Web.ApiSpec - alias Pleroma.Web.ApiSpec.Schemas.DomainBlocksResponse import Pleroma.Factory - import OpenApiSpex.TestAssertions test "blocking / unblocking a domain" do %{user: user, conn: conn} = oauth_access(["write:blocks"]) @@ -21,7 +18,7 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do |> put_req_header("content-type", "application/json") |> post("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"}) - assert %{} = json_response(ret_conn, 200) + assert %{} == json_response_and_validate_schema(ret_conn, 200) user = User.get_cached_by_ap_id(user.ap_id) assert User.blocks?(user, other_user) @@ -30,7 +27,7 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do |> put_req_header("content-type", "application/json") |> delete("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"}) - assert %{} = json_response(ret_conn, 200) + assert %{} == json_response_and_validate_schema(ret_conn, 200) user = User.get_cached_by_ap_id(user.ap_id) refute User.blocks?(user, other_user) end @@ -41,21 +38,10 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do {:ok, user} = User.block_domain(user, "bad.site") {:ok, user} = User.block_domain(user, "even.worse.site") - conn = - conn - |> assign(:user, user) - |> get("/api/v1/domain_blocks") - - domain_blocks = json_response(conn, 200) - - assert "bad.site" in domain_blocks - assert "even.worse.site" in domain_blocks - assert_schema(domain_blocks, "DomainBlocksResponse", ApiSpec.spec()) - end - - test "DomainBlocksResponse example matches schema" do - api_spec = ApiSpec.spec() - schema = DomainBlocksResponse.schema() - assert_schema(schema.example, "DomainBlocksResponse", api_spec) + assert ["even.worse.site", "bad.site"] == + conn + |> assign(:user, user) + |> get("/api/v1/domain_blocks") + |> json_response_and_validate_schema(200) end end |