logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

fallback_test.exs (2496B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.FallbackTest do
  5. use Pleroma.Web.ConnCase
  6. import Pleroma.Factory
  7. describe "neither preloaded data nor metadata attached to" do
  8. test "GET /registration/:token", %{conn: conn} do
  9. response = get(conn, "/registration/foo")
  10. assert html_response(response, 200) =~ "<!--server-generated-meta-->"
  11. end
  12. test "GET /*path", %{conn: conn} do
  13. assert conn
  14. |> get("/foo")
  15. |> html_response(200) =~ "<!--server-generated-meta-->"
  16. end
  17. end
  18. describe "preloaded data and metadata attached to" do
  19. test "GET /:maybe_nickname_or_id", %{conn: conn} do
  20. user = insert(:user)
  21. user_missing = get(conn, "/foo")
  22. user_present = get(conn, "/#{user.nickname}")
  23. assert(html_response(user_missing, 200) =~ "<!--server-generated-meta-->")
  24. refute html_response(user_present, 200) =~ "<!--server-generated-meta-->"
  25. assert html_response(user_present, 200) =~ "initial-results"
  26. end
  27. test "GET /*path", %{conn: conn} do
  28. assert conn
  29. |> get("/foo")
  30. |> html_response(200) =~ "<!--server-generated-meta-->"
  31. refute conn
  32. |> get("/foo/bar")
  33. |> html_response(200) =~ "<!--server-generated-meta-->"
  34. end
  35. end
  36. describe "preloaded data is attached to" do
  37. test "GET /main/public", %{conn: conn} do
  38. public_page = get(conn, "/main/public")
  39. refute html_response(public_page, 200) =~ "<!--server-generated-meta-->"
  40. assert html_response(public_page, 200) =~ "initial-results"
  41. end
  42. test "GET /main/all", %{conn: conn} do
  43. public_page = get(conn, "/main/all")
  44. refute html_response(public_page, 200) =~ "<!--server-generated-meta-->"
  45. assert html_response(public_page, 200) =~ "initial-results"
  46. end
  47. end
  48. test "GET /api*path", %{conn: conn} do
  49. assert conn
  50. |> get("/api/foo")
  51. |> json_response(404) == %{"error" => "Not implemented"}
  52. end
  53. test "GET /pleroma/admin -> /pleroma/admin/", %{conn: conn} do
  54. assert redirected_to(get(conn, "/pleroma/admin")) =~ "/pleroma/admin/"
  55. end
  56. test "OPTIONS /*path", %{conn: conn} do
  57. assert conn
  58. |> options("/foo")
  59. |> response(204) == ""
  60. assert conn
  61. |> options("/foo/bar")
  62. |> response(204) == ""
  63. end
  64. end