From: Alexander Strizhakov Date: Wed, 15 Jan 2020 14:10:33 +0000 (+0300) Subject: little cleanup X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=59ba5c80b97b3cef2286716573d9697e82dd2a94;p=akkoma little cleanup --- diff --git a/lib/pleroma/config/transfer_task.ex b/lib/pleroma/config/transfer_task.ex index 75c4aa739..56abfe2a5 100644 --- a/lib/pleroma/config/transfer_task.ex +++ b/lib/pleroma/config/transfer_task.ex @@ -17,7 +17,7 @@ defmodule Pleroma.Config.TransferTask 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 diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index ce5411e8a..99fcc080c 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -847,7 +847,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController 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( diff --git a/test/config/transfer_task_test.exs b/test/config/transfer_task_test.exs index b05191eab..b684956b6 100644 --- a/test/config/transfer_task_test.exs +++ b/test/config/transfer_task_test.exs @@ -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 diff --git a/test/support/helpers.ex b/test/support/helpers.ex index af2b2eddf..9f817622d 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -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 @@ defmodule Pleroma.Tests.Helpers 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 @@ defmodule Pleroma.Tests.Helpers 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 @@ defmodule Pleroma.Tests.Helpers do 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 diff --git a/test/tasks/config_test.exs b/test/tasks/config_test.exs index b967dfdde..099b3d8e3 100644 --- a/test/tasks/config_test.exs +++ b/test/tasks/config_test.exs @@ -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 diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 610fa5271..faefe729e 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -1860,14 +1860,14 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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")