little cleanup
This commit is contained in:
parent
66de2b159b
commit
59ba5c80b9
|
@ -17,7 +17,7 @@ def start_link(_) do
|
|||
end
|
||||
|
||||
def load_and_update_env do
|
||||
with true <- Pleroma.Config.get([:configurable_from_database]),
|
||||
with true <- Pleroma.Config.get(:configurable_from_database),
|
||||
true <- Ecto.Adapters.SQL.table_exists?(Repo, "config"),
|
||||
started_applications <- Application.started_applications() do
|
||||
# We need to restart applications for loaded settings take effect
|
||||
|
|
|
@ -847,7 +847,7 @@ def config_update(conn, %{"configs" => configs}) do
|
|||
end
|
||||
|
||||
defp configurable_from_database(conn) do
|
||||
if Pleroma.Config.get([:configurable_from_database]) do
|
||||
if Pleroma.Config.get(:configurable_from_database) do
|
||||
:ok
|
||||
else
|
||||
errors(
|
||||
|
|
|
@ -7,8 +7,8 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
|
||||
alias Pleroma.Web.AdminAPI.Config
|
||||
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
test "transfer config values from db to env" do
|
||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Tests.Helpers do
|
|||
@moduledoc """
|
||||
Helpers for use in tests.
|
||||
"""
|
||||
alias Pleroma.Config
|
||||
|
||||
defmacro clear_config(config_path) do
|
||||
quote do
|
||||
|
@ -17,9 +18,9 @@ defmacro clear_config(config_path) do
|
|||
defmacro clear_config(config_path, do: yield) do
|
||||
quote do
|
||||
setup do
|
||||
initial_setting = Pleroma.Config.get(unquote(config_path))
|
||||
initial_setting = Config.get(unquote(config_path))
|
||||
unquote(yield)
|
||||
on_exit(fn -> Pleroma.Config.put(unquote(config_path), initial_setting) end)
|
||||
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
@ -35,9 +36,9 @@ defmacro clear_config_all(config_path) do
|
|||
defmacro clear_config_all(config_path, do: yield) do
|
||||
quote do
|
||||
setup_all do
|
||||
initial_setting = Pleroma.Config.get(unquote(config_path))
|
||||
initial_setting = Config.get(unquote(config_path))
|
||||
unquote(yield)
|
||||
on_exit(fn -> Pleroma.Config.put(unquote(config_path), initial_setting) end)
|
||||
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
@ -94,10 +95,10 @@ def stringify_keys(key), do: key
|
|||
|
||||
defmacro guards_config(config_path) do
|
||||
quote do
|
||||
initial_setting = Pleroma.Config.get(config_path)
|
||||
initial_setting = Config.get(config_path)
|
||||
|
||||
Pleroma.Config.put(config_path, true)
|
||||
on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end)
|
||||
Config.put(config_path, true)
|
||||
on_exit(fn -> Config.put(config_path, initial_setting) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,8 +19,8 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
clear_config_all(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
test "settings are migrated to db" do
|
||||
|
|
|
@ -1860,14 +1860,14 @@ test "returns error when status is not exist", %{conn: conn} do
|
|||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/config" do
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
test "when configuration from database is off", %{conn: conn} do
|
||||
initial = Pleroma.Config.get([:configurable_from_database])
|
||||
Pleroma.Config.put([:configurable_from_database], false)
|
||||
on_exit(fn -> Pleroma.Config.put([:configurable_from_database], initial) end)
|
||||
initial = Pleroma.Config.get(:configurable_from_database)
|
||||
Pleroma.Config.put(:configurable_from_database, false)
|
||||
on_exit(fn -> Pleroma.Config.put(:configurable_from_database, initial) end)
|
||||
conn = get(conn, "/api/pleroma/admin/config")
|
||||
|
||||
assert json_response(conn, 400) ==
|
||||
|
@ -1932,8 +1932,8 @@ test "POST /api/pleroma/admin/config error", %{conn: conn} do
|
|||
end)
|
||||
end
|
||||
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
|
@ -2822,8 +2822,8 @@ test "proxy tuple ip", %{conn: conn} do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
clear_config(:configurable_from_database) do
|
||||
Pleroma.Config.put(:configurable_from_database, true)
|
||||
end
|
||||
|
||||
clear_config([:feed, :post_title]) do
|
||||
|
@ -2843,9 +2843,9 @@ test "transfer settings to DB and to file", %{conn: conn} do
|
|||
end
|
||||
|
||||
test "returns error if configuration from database is off", %{conn: conn} do
|
||||
initial = Pleroma.Config.get([:configurable_from_database])
|
||||
on_exit(fn -> Pleroma.Config.put([:configurable_from_database], initial) end)
|
||||
Pleroma.Config.put([:configurable_from_database], false)
|
||||
initial = Pleroma.Config.get(:configurable_from_database)
|
||||
on_exit(fn -> Pleroma.Config.put(:configurable_from_database, initial) end)
|
||||
Pleroma.Config.put(:configurable_from_database, false)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
|
|
Loading…
Reference in New Issue