Preloaders: Use strings as keys.

This commit is contained in:
lain 2020-06-29 11:41:00 +02:00
parent a19f8778af
commit 8630a6c7f5
8 changed files with 13 additions and 13 deletions

View File

@ -8,9 +8,9 @@ defmodule Pleroma.Web.Preload.Providers.Instance do
alias Pleroma.Web.Preload.Providers.Provider
@behaviour Provider
@instance_url :"/api/v1/instance"
@panel_url :"/instance/panel.html"
@nodeinfo_url :"/nodeinfo/2.0.json"
@instance_url "/api/v1/instance"
@panel_url "/instance/panel.html"
@nodeinfo_url "/nodeinfo/2.0.json"
@impl Provider
def generate_terms(_params) do

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.Preload.Providers.StatusNet do
alias Pleroma.Web.TwitterAPI.UtilController
@behaviour Provider
@config_url :"/api/statusnet/config.json"
@config_url "/api/statusnet/config.json"
@impl Provider
def generate_terms(_params) do

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.Timelines do
alias Pleroma.Web.Preload.Providers.Provider
@behaviour Provider
@public_url :"/api/v1/timelines/public"
@public_url "/api/v1/timelines/public"
@impl Provider
def generate_terms(params) do

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.User do
alias Pleroma.Web.Preload.Providers.Provider
@behaviour Provider
@account_url_base :"/api/v1/accounts"
@account_url_base "/api/v1/accounts"
@impl Provider
def generate_terms(%{user: user}) do
@ -19,7 +19,7 @@ def generate_terms(_params), do: %{}
def build_accounts_tag(acc, %User{} = user) do
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
def build_accounts_tag(acc, _), do: acc

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.InstanceTest do
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 %{
description: description,
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")
end
test "it renders the panel", %{"/instance/panel.html": panel} do
test "it renders the panel", %{"/instance/panel.html" => panel} do
assert String.contains?(
panel,
"<p>Welcome to <a href=\"https://pleroma.social\" target=\"_blank\">Pleroma!</a></p>"
)
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,
version: "2.0"

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.StatusNetTest do
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 res["site"]
end

View File

@ -9,7 +9,7 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Preload.Providers.Timelines
@public_url :"/api/v1/timelines/public"
@public_url "/api/v1/timelines/public"
describe "unauthenticated timeliness when restricted" do
setup do

View File

@ -26,7 +26,7 @@ test "missing user specified" do
end
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
end
end