Fix OpenAPI spec for preferred_frontend endpoint
The spec was copied from another endpoint, including the operation id, leading to scrubbing the valid parameters from the request and simply not working. Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
bb44501a9e
commit
8827e51170
3 changed files with 22 additions and 10 deletions
|
|
@ -30,9 +30,9 @@ defmodule Pleroma.Web.ApiSpec.PleromaFrontendSettingsOperation do
|
||||||
def update_preferred_frontend_operation() do
|
def update_preferred_frontend_operation() do
|
||||||
%Operation{
|
%Operation{
|
||||||
tags: ["Frontends"],
|
tags: ["Frontends"],
|
||||||
summary: "Frontend Settings Profiles",
|
summary: "Update preferred frontend setting",
|
||||||
description: "List frontend setting profiles",
|
description: "Store preferred frontend in cookies",
|
||||||
operationId: "PleromaAPI.FrontendSettingsController.available_frontends",
|
operationId: "PleromaAPI.FrontendSettingsController.update_preferred_frontend",
|
||||||
requestBody:
|
requestBody:
|
||||||
request_body(
|
request_body(
|
||||||
"Frontend",
|
"Frontend",
|
||||||
|
|
|
||||||
|
|
@ -81,15 +81,8 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
def preferred_or_fallback(conn, fallback), do: fallback
|
def preferred_or_fallback(conn, fallback), do: fallback
|
||||||
|
|
||||||
defp enabled?(if_opt) when is_function(if_opt), do: if_opt.()
|
|
||||||
defp enabled?(true), do: true
|
|
||||||
defp enabled?(_), do: false
|
|
||||||
|
|
||||||
>>>>>>> de64c6c54a (add selection UI)
|
|
||||||
defp invalid_path?(list) do
|
defp invalid_path?(list) do
|
||||||
invalid_path?(list, :binary.compile_pattern(["/", "\\", ":", "\0"]))
|
invalid_path?(list, :binary.compile_pattern(["/", "\\", ":", "\0"]))
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
defmodule Pleroma.Web.PleromaAPI.FrontendSettingsControllerTest do
|
||||||
|
use Pleroma.Web.ConnCase, async: false
|
||||||
|
|
||||||
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
describe "PUT /api/v1/pleroma/preferred_frontend" do
|
||||||
|
test "sets a cookie with selected frontend" do
|
||||||
|
%{conn: conn} = oauth_access(["read"])
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> put("/api/v1/pleroma/preferred_frontend", %{"frontend_name" => "pleroma-fe/stable"})
|
||||||
|
|
||||||
|
json_response_and_validate_schema(response, 200)
|
||||||
|
assert %{"preferred_frontend" => %{value: "pleroma-fe/stable"}} = response.resp_cookies
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue