Migrated from old settings module to new one
This commit is contained in:
parent
3a6930457b
commit
e84f6d3ef4
20 changed files with 75 additions and 67 deletions
2
.iex.exs
2
.iex.exs
|
|
@ -11,7 +11,7 @@ alias Pinchflat.Tasks
|
||||||
alias Pinchflat.Media
|
alias Pinchflat.Media
|
||||||
alias Pinchflat.Profiles
|
alias Pinchflat.Profiles
|
||||||
alias Pinchflat.Sources
|
alias Pinchflat.Sources
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
alias Pinchflat.Downloading.MediaDownloader
|
alias Pinchflat.Downloading.MediaDownloader
|
||||||
alias Pinchflat.YtDlp.Media, as: YtDlpMedia
|
alias Pinchflat.YtDlp.Media, as: YtDlpMedia
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
alias Pinchflat.Repo
|
alias Pinchflat.Repo
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
alias Pinchflat.YtDlp.CommandRunner
|
alias Pinchflat.YtDlp.CommandRunner
|
||||||
alias Pinchflat.Filesystem.FilesystemHelpers
|
alias Pinchflat.Filesystem.FilesystemHelpers
|
||||||
|
|
||||||
|
|
@ -65,8 +65,6 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
|
||||||
defp apply_default_settings do
|
defp apply_default_settings do
|
||||||
{:ok, yt_dlp_version} = CommandRunner.version()
|
{:ok, yt_dlp_version} = CommandRunner.version()
|
||||||
|
|
||||||
SettingsBackup.fetch!(:onboarding, true)
|
Settings.set(yt_dlp_version: yt_dlp_version)
|
||||||
SettingsBackup.fetch!(:pro_enabled, false)
|
|
||||||
SettingsBackup.set!(:yt_dlp_version, yt_dlp_version)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ defmodule Pinchflat.Settings.Setting do
|
||||||
)a
|
)a
|
||||||
|
|
||||||
schema "settings" do
|
schema "settings" do
|
||||||
field :onboarding, :boolean, default: false
|
field :onboarding, :boolean, default: true
|
||||||
field :pro_enabled, :boolean, default: false
|
field :pro_enabled, :boolean, default: false
|
||||||
field :yt_dlp_version, :string
|
field :yt_dlp_version, :string
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ defmodule PinchflatWeb do
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import PinchflatWeb.Gettext
|
import PinchflatWeb.Gettext
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
alias PinchflatWeb.Layouts
|
alias PinchflatWeb.Layouts
|
||||||
|
|
||||||
unquote(verified_routes())
|
unquote(verified_routes())
|
||||||
|
|
@ -58,7 +58,7 @@ defmodule PinchflatWeb do
|
||||||
|
|
||||||
use Phoenix.LiveView
|
use Phoenix.LiveView
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
end
|
end
|
||||||
|
|
@ -68,7 +68,7 @@ defmodule PinchflatWeb do
|
||||||
quote do
|
quote do
|
||||||
use Phoenix.LiveComponent
|
use Phoenix.LiveComponent
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
end
|
end
|
||||||
|
|
@ -82,7 +82,7 @@ defmodule PinchflatWeb do
|
||||||
import Phoenix.Controller,
|
import Phoenix.Controller,
|
||||||
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
# Include general helpers for rendering HTML
|
# Include general helpers for rendering HTML
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
|
|
@ -101,7 +101,7 @@ defmodule PinchflatWeb do
|
||||||
import PinchflatWeb.CustomComponents.TableComponents
|
import PinchflatWeb.CustomComponents.TableComponents
|
||||||
import PinchflatWeb.CustomComponents.ButtonComponents
|
import PinchflatWeb.CustomComponents.ButtonComponents
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
alias Pinchflat.Utils.StringUtils
|
alias Pinchflat.Utils.StringUtils
|
||||||
|
|
||||||
# Shortcut for generating JS commands
|
# Shortcut for generating JS commands
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
Pinchflat v<%= Application.spec(:pinchflat)[:vsn] %>
|
Pinchflat v<%= Application.spec(:pinchflat)[:vsn] %>
|
||||||
</span>
|
</span>
|
||||||
<span class="group relative flex items-center gap-2.5 px-4 text-sm">
|
<span class="group relative flex items-center gap-2.5 px-4 text-sm">
|
||||||
yt-dlp <%= SettingsBackup.get!(:yt_dlp_version) %>
|
yt-dlp <%= Settings.get!(:yt_dlp_version) %>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ defmodule Pinchflat.UpgradeButtonLive do
|
||||||
|> String.downcase()
|
|> String.downcase()
|
||||||
|
|
||||||
if normalized_text == "got it!" do
|
if normalized_text == "got it!" do
|
||||||
SettingsBackup.set!(:pro_enabled, true)
|
Settings.set(pro_enabled: true)
|
||||||
|
|
||||||
{:noreply, update(socket, :button_disabled, fn _ -> false end)}
|
{:noreply, update(socket, :button_disabled, fn _ -> false end)}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
<body
|
<body
|
||||||
x-data={"{
|
x-data={"{
|
||||||
sidebarVisible: false,
|
sidebarVisible: false,
|
||||||
proEnabled: #{SettingsBackup.get!(:pro_enabled)},
|
proEnabled: #{Settings.get!(:pro_enabled)},
|
||||||
onboarding: #{SettingsBackup.get!(:onboarding)}
|
onboarding: #{Settings.get!(:onboarding)}
|
||||||
}"}
|
}"}
|
||||||
class="dark text-bodydark bg-boxdark-2"
|
class="dark text-bodydark bg-boxdark-2"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileController do
|
||||||
case Profiles.create_media_profile(media_profile_params) do
|
case Profiles.create_media_profile(media_profile_params) do
|
||||||
{:ok, media_profile} ->
|
{:ok, media_profile} ->
|
||||||
redirect_location =
|
redirect_location =
|
||||||
if SettingsBackup.get!(:onboarding), do: ~p"/?onboarding=1", else: ~p"/media_profiles/#{media_profile}"
|
if Settings.get!(:onboarding), do: ~p"/?onboarding=1", else: ~p"/media_profiles/#{media_profile}"
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Media profile created successfully.")
|
|> put_flash(:info, "Media profile created successfully.")
|
||||||
|
|
@ -89,7 +89,7 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_onboarding_layout do
|
defp get_onboarding_layout do
|
||||||
if SettingsBackup.get!(:onboarding) do
|
if Settings.get!(:onboarding) do
|
||||||
{Layouts, :onboarding}
|
{Layouts, :onboarding}
|
||||||
else
|
else
|
||||||
{Layouts, :app}
|
{Layouts, :app}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="mb-6 flex gap-3 flex-row items-center">
|
<div class="mb-6 flex gap-3 flex-row items-center">
|
||||||
<.link :if={!SettingsBackup.get!(:onboarding)} href={~p"/media_profiles"}>
|
<.link :if={!Settings.get!(:onboarding)} href={~p"/media_profiles"}>
|
||||||
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
|
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
|
||||||
</.link>
|
</.link>
|
||||||
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">New Media Profile</h2>
|
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">New Media Profile</h2>
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ defmodule PinchflatWeb.Pages.PageController do
|
||||||
done_onboarding = params["onboarding"] == "0"
|
done_onboarding = params["onboarding"] == "0"
|
||||||
force_onboarding = params["onboarding"] == "1"
|
force_onboarding = params["onboarding"] == "1"
|
||||||
|
|
||||||
if done_onboarding, do: SettingsBackup.set!(:onboarding, false)
|
if done_onboarding, do: Settings.set(onboarding: false)
|
||||||
|
|
||||||
if force_onboarding || SettingsBackup.get!(:onboarding) do
|
if force_onboarding || Settings.get!(:onboarding) do
|
||||||
render_onboarding_page(conn)
|
render_onboarding_page(conn)
|
||||||
else
|
else
|
||||||
render_home_page(conn)
|
render_home_page(conn)
|
||||||
|
|
@ -30,7 +30,7 @@ defmodule PinchflatWeb.Pages.PageController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_onboarding_page(conn) do
|
defp render_onboarding_page(conn) do
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(:onboarding_checklist,
|
|> render(:onboarding_checklist,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ defmodule PinchflatWeb.Sources.SourceController do
|
||||||
case Sources.create_source(source_params) do
|
case Sources.create_source(source_params) do
|
||||||
{:ok, source} ->
|
{:ok, source} ->
|
||||||
redirect_location =
|
redirect_location =
|
||||||
if SettingsBackup.get!(:onboarding), do: ~p"/?onboarding=1", else: ~p"/sources/#{source}"
|
if Settings.get!(:onboarding), do: ~p"/?onboarding=1", else: ~p"/sources/#{source}"
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Source created successfully.")
|
|> put_flash(:info, "Source created successfully.")
|
||||||
|
|
@ -159,7 +159,7 @@ defmodule PinchflatWeb.Sources.SourceController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_onboarding_layout do
|
defp get_onboarding_layout do
|
||||||
if SettingsBackup.get!(:onboarding) do
|
if Settings.get!(:onboarding) do
|
||||||
{Layouts, :onboarding}
|
{Layouts, :onboarding}
|
||||||
else
|
else
|
||||||
{Layouts, :app}
|
{Layouts, :app}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="mb-6 flex gap-3 flex-row items-center">
|
<div class="mb-6 flex gap-3 flex-row items-center">
|
||||||
<.link :if={!SettingsBackup.get!(:onboarding)} href={~p"/sources"}>
|
<.link :if={!Settings.get!(:onboarding)} href={~p"/sources"}>
|
||||||
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
|
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
|
||||||
</.link>
|
</.link>
|
||||||
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">New Source</h2>
|
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">New Source</h2>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Pinchflat.Repo.Migrations.CreateSettingsBackup do
|
defmodule Pinchflat.Repo.Migrations.CreateSettings do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
def change do
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule Pinchflat.Repo.Migrations.RenameSettingsBackupTable do
|
defmodule Pinchflat.Repo.Migrations.RenameSettingsTable do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
def change do
|
||||||
|
|
|
||||||
29
priv/repo/migrations/20240404174144_create_new_settings.exs
Normal file
29
priv/repo/migrations/20240404174144_create_new_settings.exs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
defmodule Pinchflat.Repo.Migrations.CreateNewSettings do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
create table(:settings) do
|
||||||
|
add :onboarding, :boolean, default: true, null: false
|
||||||
|
add :pro_enabled, :boolean, default: false, null: false
|
||||||
|
add :yt_dlp_version, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
# Make an initial record because this will be the only one ever inserted
|
||||||
|
execute "INSERT INTO settings (onboarding, pro_enabled, yt_dlp_version) VALUES (true, false, NULL)"
|
||||||
|
|
||||||
|
# Set the value of onboarding to the previous version set in `settings_backup`
|
||||||
|
execute """
|
||||||
|
UPDATE settings
|
||||||
|
SET onboarding = COALESCE((SELECT value = 'true' FROM settings_backup WHERE name = 'onboarding'), true)
|
||||||
|
"""
|
||||||
|
|
||||||
|
execute """
|
||||||
|
UPDATE settings
|
||||||
|
SET pro_enabled = COALESCE((SELECT value = 'true' FROM settings_backup WHERE name = 'pro_enabled'), false)
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
drop table(:settings)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
defmodule Pinchflat.Repo.Migrations.CreateSettings do
|
|
||||||
use Ecto.Migration
|
|
||||||
|
|
||||||
def up do
|
|
||||||
create table(:settings) do
|
|
||||||
add :onboarding, :boolean, default: false, null: false
|
|
||||||
add :pro_enabled, :boolean, default: false, null: false
|
|
||||||
add :yt_dlp_version, :string
|
|
||||||
end
|
|
||||||
|
|
||||||
# Make an initial record because this will be the only one ever inserted
|
|
||||||
execute "INSERT INTO settings (onboarding, pro_enabled, yt_dlp_version) VALUES (false, false, NULL)"
|
|
||||||
end
|
|
||||||
|
|
||||||
def down do
|
|
||||||
drop table(:settings)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
defmodule Pinchflat.Boot.PreJobStartupTasksTest do
|
defmodule Pinchflat.Boot.PreJobStartupTasksTest do
|
||||||
use Pinchflat.DataCase
|
use Pinchflat.DataCase
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
alias Pinchflat.SettingsBackup.SettingBackup
|
|
||||||
alias Pinchflat.Boot.PreJobStartupTasks
|
alias Pinchflat.Boot.PreJobStartupTasks
|
||||||
|
|
||||||
|
# TODO: write tests for things like cookie file creation
|
||||||
|
|
||||||
describe "apply_default_settings" do
|
describe "apply_default_settings" do
|
||||||
setup do
|
setup do
|
||||||
Repo.delete_all(SettingBackup)
|
Settings.set(yt_dlp_version: nil)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sets default settings" do
|
test "sets default settings" do
|
||||||
assert_raise Ecto.NoResultsError, fn -> SettingsBackup.get!(:onboarding) end
|
assert Settings.get!(:yt_dlp_version) == nil
|
||||||
assert_raise Ecto.NoResultsError, fn -> SettingsBackup.get!(:pro_enabled) end
|
|
||||||
|
|
||||||
PreJobStartupTasks.start_link()
|
PreJobStartupTasks.start_link()
|
||||||
|
|
||||||
assert SettingsBackup.get!(:onboarding)
|
assert Settings.get!(:yt_dlp_version)
|
||||||
refute SettingsBackup.get!(:pro_enabled)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
|
||||||
import Pinchflat.ProfilesFixtures
|
import Pinchflat.ProfilesFixtures
|
||||||
|
|
||||||
alias Pinchflat.Repo
|
alias Pinchflat.Repo
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
@create_attrs %{name: "some name", output_path_template: "output_template.{{ ext }}"}
|
@create_attrs %{name: "some name", output_path_template: "output_template.{{ ext }}"}
|
||||||
@update_attrs %{
|
@update_attrs %{
|
||||||
|
|
@ -16,7 +16,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
|
||||||
@invalid_attrs %{name: nil, output_path_template: nil}
|
@invalid_attrs %{name: nil, output_path_template: nil}
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
SettingsBackup.set!(:onboarding, false)
|
Settings.set(onboarding: false)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
@ -35,7 +35,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders correct layout when onboarding", %{conn: conn} do
|
test "renders correct layout when onboarding", %{conn: conn} do
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
conn = get(conn, ~p"/media_profiles/new")
|
conn = get(conn, ~p"/media_profiles/new")
|
||||||
|
|
||||||
refute html_response(conn, 200) =~ "MENU"
|
refute html_response(conn, 200) =~ "MENU"
|
||||||
|
|
@ -59,14 +59,14 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "redirects to onboarding when onboarding", %{conn: conn} do
|
test "redirects to onboarding when onboarding", %{conn: conn} do
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
conn = post(conn, ~p"/media_profiles", media_profile: @create_attrs)
|
conn = post(conn, ~p"/media_profiles", media_profile: @create_attrs)
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/?onboarding=1"
|
assert redirected_to(conn) == ~p"/?onboarding=1"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders correct layout on error when onboarding", %{conn: conn} do
|
test "renders correct layout on error when onboarding", %{conn: conn} do
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
conn = post(conn, ~p"/media_profiles", media_profile: @invalid_attrs)
|
conn = post(conn, ~p"/media_profiles", media_profile: @invalid_attrs)
|
||||||
|
|
||||||
refute html_response(conn, 200) =~ "MENU"
|
refute html_response(conn, 200) =~ "MENU"
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
defmodule PinchflatWeb.PageControllerTest do
|
defmodule PinchflatWeb.PageControllerTest do
|
||||||
use PinchflatWeb.ConnCase
|
use PinchflatWeb.ConnCase
|
||||||
|
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
describe "GET / when testing onboarding" do
|
describe "GET / when testing onboarding" do
|
||||||
test "sets the onboarding setting to true when onboarding", %{conn: conn} do
|
test "sets the onboarding setting to true when onboarding", %{conn: conn} do
|
||||||
_conn = get(conn, ~p"/")
|
_conn = get(conn, ~p"/")
|
||||||
assert SettingsBackup.get!(:onboarding)
|
assert Settings.get!(:onboarding)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
||||||
SettingsBackup.set!(:onboarding, false)
|
Settings.set(onboarding: false)
|
||||||
|
|
||||||
conn = get(conn, ~p"/?onboarding=1")
|
conn = get(conn, ~p"/?onboarding=1")
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
||||||
|
|
@ -18,14 +18,14 @@ defmodule PinchflatWeb.PageControllerTest do
|
||||||
|
|
||||||
test "sets the onboarding setting to false if you pass the corrent query param", %{conn: conn} do
|
test "sets the onboarding setting to false if you pass the corrent query param", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert SettingsBackup.get!(:onboarding)
|
assert Settings.get!(:onboarding)
|
||||||
|
|
||||||
_conn = get(conn, ~p"/?onboarding=0")
|
_conn = get(conn, ~p"/?onboarding=0")
|
||||||
refute SettingsBackup.get!(:onboarding)
|
refute Settings.get!(:onboarding)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays the home page when not onboarding", %{conn: conn} do
|
test "displays the home page when not onboarding", %{conn: conn} do
|
||||||
SettingsBackup.set!(:onboarding, false)
|
Settings.set(onboarding: false)
|
||||||
|
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert html_response(conn, 200) =~ "MENU"
|
assert html_response(conn, 200) =~ "MENU"
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||||
import Pinchflat.ProfilesFixtures
|
import Pinchflat.ProfilesFixtures
|
||||||
|
|
||||||
alias Pinchflat.Repo
|
alias Pinchflat.Repo
|
||||||
alias Pinchflat.SettingsBackup
|
alias Pinchflat.Settings
|
||||||
alias Pinchflat.Downloading.MediaDownloadWorker
|
alias Pinchflat.Downloading.MediaDownloadWorker
|
||||||
alias Pinchflat.SlowIndexing.MediaCollectionIndexingWorker
|
alias Pinchflat.SlowIndexing.MediaCollectionIndexingWorker
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
media_profile = media_profile_fixture()
|
media_profile = media_profile_fixture()
|
||||||
SettingsBackup.set!(:onboarding, false)
|
Settings.set(onboarding: false)
|
||||||
|
|
||||||
{
|
{
|
||||||
:ok,
|
:ok,
|
||||||
|
|
@ -47,7 +47,7 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders correct layout when onboarding", %{conn: conn} do
|
test "renders correct layout when onboarding", %{conn: conn} do
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
conn = get(conn, ~p"/sources/new")
|
conn = get(conn, ~p"/sources/new")
|
||||||
|
|
||||||
refute html_response(conn, 200) =~ "MENU"
|
refute html_response(conn, 200) =~ "MENU"
|
||||||
|
|
@ -74,14 +74,14 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||||
test "redirects to onboarding when onboarding", %{conn: conn, create_attrs: create_attrs} do
|
test "redirects to onboarding when onboarding", %{conn: conn, create_attrs: create_attrs} do
|
||||||
expect(YtDlpRunnerMock, :run, 1, &runner_function_mock/3)
|
expect(YtDlpRunnerMock, :run, 1, &runner_function_mock/3)
|
||||||
|
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
conn = post(conn, ~p"/sources", source: create_attrs)
|
conn = post(conn, ~p"/sources", source: create_attrs)
|
||||||
|
|
||||||
assert redirected_to(conn) == ~p"/?onboarding=1"
|
assert redirected_to(conn) == ~p"/?onboarding=1"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "renders correct layout on error when onboarding", %{conn: conn, invalid_attrs: invalid_attrs} do
|
test "renders correct layout on error when onboarding", %{conn: conn, invalid_attrs: invalid_attrs} do
|
||||||
SettingsBackup.set!(:onboarding, true)
|
Settings.set(onboarding: true)
|
||||||
conn = post(conn, ~p"/sources", source: invalid_attrs)
|
conn = post(conn, ~p"/sources", source: invalid_attrs)
|
||||||
|
|
||||||
refute html_response(conn, 200) =~ "MENU"
|
refute html_response(conn, 200) =~ "MENU"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue