forked from AkkomaGang/akkoma
Preloaders: Use strings as keys.
This commit is contained in:
parent
a19f8778af
commit
8630a6c7f5
8 changed files with 13 additions and 13 deletions
|
@ -8,9 +8,9 @@ defmodule Pleroma.Web.Preload.Providers.Instance do
|
||||||
alias Pleroma.Web.Preload.Providers.Provider
|
alias Pleroma.Web.Preload.Providers.Provider
|
||||||
|
|
||||||
@behaviour Provider
|
@behaviour Provider
|
||||||
@instance_url :"/api/v1/instance"
|
@instance_url "/api/v1/instance"
|
||||||
@panel_url :"/instance/panel.html"
|
@panel_url "/instance/panel.html"
|
||||||
@nodeinfo_url :"/nodeinfo/2.0.json"
|
@nodeinfo_url "/nodeinfo/2.0.json"
|
||||||
|
|
||||||
@impl Provider
|
@impl Provider
|
||||||
def generate_terms(_params) do
|
def generate_terms(_params) do
|
||||||
|
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.Preload.Providers.StatusNet do
|
||||||
alias Pleroma.Web.TwitterAPI.UtilController
|
alias Pleroma.Web.TwitterAPI.UtilController
|
||||||
|
|
||||||
@behaviour Provider
|
@behaviour Provider
|
||||||
@config_url :"/api/statusnet/config.json"
|
@config_url "/api/statusnet/config.json"
|
||||||
|
|
||||||
@impl Provider
|
@impl Provider
|
||||||
def generate_terms(_params) do
|
def generate_terms(_params) do
|
||||||
|
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.Timelines do
|
||||||
alias Pleroma.Web.Preload.Providers.Provider
|
alias Pleroma.Web.Preload.Providers.Provider
|
||||||
|
|
||||||
@behaviour Provider
|
@behaviour Provider
|
||||||
@public_url :"/api/v1/timelines/public"
|
@public_url "/api/v1/timelines/public"
|
||||||
|
|
||||||
@impl Provider
|
@impl Provider
|
||||||
def generate_terms(params) do
|
def generate_terms(params) do
|
||||||
|
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.User do
|
||||||
alias Pleroma.Web.Preload.Providers.Provider
|
alias Pleroma.Web.Preload.Providers.Provider
|
||||||
|
|
||||||
@behaviour Provider
|
@behaviour Provider
|
||||||
@account_url_base :"/api/v1/accounts"
|
@account_url_base "/api/v1/accounts"
|
||||||
|
|
||||||
@impl Provider
|
@impl Provider
|
||||||
def generate_terms(%{user: user}) do
|
def generate_terms(%{user: user}) do
|
||||||
|
@ -19,7 +19,7 @@ def generate_terms(_params), do: %{}
|
||||||
|
|
||||||
def build_accounts_tag(acc, %User{} = user) do
|
def build_accounts_tag(acc, %User{} = user) do
|
||||||
account_data = AccountView.render("show.json", %{user: user, for: user})
|
account_data = AccountView.render("show.json", %{user: user, for: user})
|
||||||
Map.put(acc, :"#{@account_url_base}/#{user.id}", account_data)
|
Map.put(acc, "#{@account_url_base}/#{user.id}", account_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_accounts_tag(acc, _), do: acc
|
def build_accounts_tag(acc, _), do: acc
|
||||||
|
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.InstanceTest do
|
||||||
|
|
||||||
setup do: {:ok, Instance.generate_terms(nil)}
|
setup do: {:ok, Instance.generate_terms(nil)}
|
||||||
|
|
||||||
test "it renders the info", %{"/api/v1/instance": info} do
|
test "it renders the info", %{"/api/v1/instance" => info} do
|
||||||
assert %{
|
assert %{
|
||||||
description: description,
|
description: description,
|
||||||
email: "admin@example.com",
|
email: "admin@example.com",
|
||||||
|
@ -18,14 +18,14 @@ test "it renders the info", %{"/api/v1/instance": info} do
|
||||||
assert String.equivalent?(description, "Pleroma: An efficient and flexible fediverse server")
|
assert String.equivalent?(description, "Pleroma: An efficient and flexible fediverse server")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it renders the panel", %{"/instance/panel.html": panel} do
|
test "it renders the panel", %{"/instance/panel.html" => panel} do
|
||||||
assert String.contains?(
|
assert String.contains?(
|
||||||
panel,
|
panel,
|
||||||
"<p>Welcome to <a href=\"https://pleroma.social\" target=\"_blank\">Pleroma!</a></p>"
|
"<p>Welcome to <a href=\"https://pleroma.social\" target=\"_blank\">Pleroma!</a></p>"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it renders the node_info", %{"/nodeinfo/2.0.json": nodeinfo} do
|
test "it renders the node_info", %{"/nodeinfo/2.0.json" => nodeinfo} do
|
||||||
%{
|
%{
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
version: "2.0"
|
version: "2.0"
|
||||||
|
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.StatusNetTest do
|
||||||
|
|
||||||
setup do: {:ok, StatusNet.generate_terms(nil)}
|
setup do: {:ok, StatusNet.generate_terms(nil)}
|
||||||
|
|
||||||
test "it renders the info", %{"/api/statusnet/config.json": info} do
|
test "it renders the info", %{"/api/statusnet/config.json" => info} do
|
||||||
assert {:ok, res} = Jason.decode(info)
|
assert {:ok, res} = Jason.decode(info)
|
||||||
assert res["site"]
|
assert res["site"]
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.Preload.Providers.Timelines
|
alias Pleroma.Web.Preload.Providers.Timelines
|
||||||
|
|
||||||
@public_url :"/api/v1/timelines/public"
|
@public_url "/api/v1/timelines/public"
|
||||||
|
|
||||||
describe "unauthenticated timeliness when restricted" do
|
describe "unauthenticated timeliness when restricted" do
|
||||||
setup do
|
setup do
|
||||||
|
|
|
@ -26,7 +26,7 @@ test "missing user specified" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "account is rendered", %{terms: terms, user: user} do
|
test "account is rendered", %{terms: terms, user: user} do
|
||||||
account = terms[:"/api/v1/accounts/#{user.id}"]
|
account = terms["/api/v1/accounts/#{user.id}"]
|
||||||
assert %{acct: user, username: user} = account
|
assert %{acct: user, username: user} = account
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue