diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/filter_test.exs | 10 | ||||
| -rw-r--r-- | test/web/mastodon_api/controllers/filter_controller_test.exs | 26 | 
2 files changed, 20 insertions, 16 deletions
| diff --git a/test/filter_test.exs b/test/filter_test.exs index b2a8330ee..63a30c736 100644 --- a/test/filter_test.exs +++ b/test/filter_test.exs @@ -141,17 +141,15 @@ defmodule Pleroma.FilterTest do        context: ["home"]      } -    query_two = %Pleroma.Filter{ -      user_id: user.id, -      filter_id: 1, +    changes = %{        phrase: "who",        context: ["home", "timeline"]      }      {:ok, filter_one} = Pleroma.Filter.create(query_one) -    {:ok, filter_two} = Pleroma.Filter.update(query_two) +    {:ok, filter_two} = Pleroma.Filter.update(filter_one, changes)      assert filter_one != filter_two -    assert filter_two.phrase == query_two.phrase -    assert filter_two.context == query_two.context +    assert filter_two.phrase == changes.phrase +    assert filter_two.context == changes.context    end  end diff --git a/test/web/mastodon_api/controllers/filter_controller_test.exs b/test/web/mastodon_api/controllers/filter_controller_test.exs index 97ab005e0..f29547d13 100644 --- a/test/web/mastodon_api/controllers/filter_controller_test.exs +++ b/test/web/mastodon_api/controllers/filter_controller_test.exs @@ -15,9 +15,12 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do        context: ["home"]      } -    conn = post(conn, "/api/v1/filters", %{"phrase" => filter.phrase, context: filter.context}) +    conn = +      conn +      |> put_req_header("content-type", "application/json") +      |> post("/api/v1/filters", %{"phrase" => filter.phrase, context: filter.context}) -    assert response = json_response(conn, 200) +    assert response = json_response_and_validate_schema(conn, 200)      assert response["phrase"] == filter.phrase      assert response["context"] == filter.context      assert response["irreversible"] == false @@ -48,12 +51,12 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do      response =        conn        |> get("/api/v1/filters") -      |> json_response(200) +      |> json_response_and_validate_schema(200)      assert response ==               render_json(                 FilterView, -               "filters.json", +               "index.json",                 filters: [filter_two, filter_one]               )    end @@ -72,7 +75,7 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do      conn = get(conn, "/api/v1/filters/#{filter.filter_id}") -    assert _response = json_response(conn, 200) +    assert response = json_response_and_validate_schema(conn, 200)    end    test "update a filter" do @@ -82,7 +85,8 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do        user_id: user.id,        filter_id: 2,        phrase: "knight", -      context: ["home"] +      context: ["home"], +      hide: true      }      {:ok, _filter} = Pleroma.Filter.create(query) @@ -93,14 +97,17 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do      }      conn = -      put(conn, "/api/v1/filters/#{query.filter_id}", %{ +      conn +      |> put_req_header("content-type", "application/json") +      |> put("/api/v1/filters/#{query.filter_id}", %{          phrase: new.phrase,          context: new.context        }) -    assert response = json_response(conn, 200) +    assert response = json_response_and_validate_schema(conn, 200)      assert response["phrase"] == new.phrase      assert response["context"] == new.context +    assert response["irreversible"] == true    end    test "delete a filter" do @@ -117,7 +124,6 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do      conn = delete(conn, "/api/v1/filters/#{filter.filter_id}") -    assert response = json_response(conn, 200) -    assert response == %{} +    assert json_response_and_validate_schema(conn, 200) == %{}    end  end | 
