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
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(
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
@moduledoc """
Helpers for use in tests.
"""
+ alias Pleroma.Config
defmacro clear_config(config_path) do
quote 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
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
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
: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
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) ==
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
: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
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")