Commit 6b87dfad authored by feld's avatar feld
Browse files

Filter out MIX_ENV from route list and add a test

parent 8ad16137
Pipeline #35165 passed with stages
in 6 minutes and 18 seconds
......@@ -28,6 +28,8 @@ defmodule Pleroma.Web do
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.PlugHelper
@mix_env Mix.env()
def controller do
quote do
use Phoenix.Controller, namespace: Pleroma.Web
......@@ -236,7 +238,11 @@ def base_url do
def get_api_routes do
Pleroma.Web.Router.__routes__()
|> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
|> Enum.reject(fn
r ->
r.plug == Pleroma.Web.Fallback.RedirectController or
String.starts_with?(r.path, "/#{@mix_env}")
end)
|> Enum.map(fn r ->
r.path
|> String.split("/", trim: true)
......
......@@ -74,4 +74,32 @@ test "exclude invalid path", %{conn: conn} do
assert %Plug.Conn{status: :success} = get(conn, url)
end
end
test "api routes are detected correctly" do
expected_routes = [
"api",
"main",
"ostatus_subscribe",
"oauth",
"objects",
"activities",
"notice",
"users",
"tags",
"mailer",
"inbox",
"relay",
"internal",
".well-known",
"nodeinfo",
"web",
"auth",
"embed",
"proxy",
"user_exists",
"check_password"
]
assert expected_routes == Pleroma.Web.get_api_routes()
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment