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
|
||||
%Operation{
|
||||
tags: ["Frontends"],
|
||||
summary: "Frontend Settings Profiles",
|
||||
description: "List frontend setting profiles",
|
||||
operationId: "PleromaAPI.FrontendSettingsController.available_frontends",
|
||||
summary: "Update preferred frontend setting",
|
||||
description: "Store preferred frontend in cookies",
|
||||
operationId: "PleromaAPI.FrontendSettingsController.update_preferred_frontend",
|
||||
requestBody:
|
||||
request_body(
|
||||
"Frontend",
|
||||
|
|
|
|||
|
|
@ -81,15 +81,8 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
|
|||
end
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
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
|
||||
invalid_path?(list, :binary.compile_pattern(["/", "\\", ":", "\0"]))
|
||||
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