diff --git a/.check.exs b/.check.exs index 4a72fcd..a6ca874 100644 --- a/.check.exs +++ b/.check.exs @@ -15,6 +15,7 @@ # {:my_arbitrary_tool, command: "npm test", cd: "assets"}, # {:my_arbitrary_script, command: ["my_script", "argument with spaces"], cd: "scripts"} {:npm_test, false}, + {:gettext, false}, {:check_migrations, command: "mix ash_postgres.generate_migrations --check"} ] ] diff --git a/lib/ash_hq/docs/importer/importer.ex b/lib/ash_hq/docs/importer/importer.ex index 9c4b0d2..2b7399a 100644 --- a/lib/ash_hq/docs/importer/importer.ex +++ b/lib/ash_hq/docs/importer/importer.ex @@ -3,7 +3,7 @@ defmodule AshHq.Docs.Importer do Builds the documentation into term files in the `priv/docs` directory. """ - def import() do + def import do AshOban.schedule_and_run_triggers(AshHq.Docs.Library) end end diff --git a/lib/ash_hq/docs/resources/library/actions/import.ex b/lib/ash_hq/docs/resources/library/actions/import.ex index b459f33..c443001 100644 --- a/lib/ash_hq/docs/resources/library/actions/import.ex +++ b/lib/ash_hq/docs/resources/library/actions/import.ex @@ -1,4 +1,5 @@ defmodule AshHq.Docs.Library.Actions.Import do + @moduledoc false use Ash.Resource.ManualUpdate require Ash.Query require Logger diff --git a/lib/ash_hq/docs/resources/library/preparations/filter_pending_import.ex b/lib/ash_hq/docs/resources/library/preparations/filter_pending_import.ex index b2f02f4..28d7a82 100644 --- a/lib/ash_hq/docs/resources/library/preparations/filter_pending_import.ex +++ b/lib/ash_hq/docs/resources/library/preparations/filter_pending_import.ex @@ -1,4 +1,5 @@ defmodule AshHq.Docs.Library.Preparations.FilterPendingImport do + @moduledoc false use Ash.Resource.Preparation def prepare(query, _opts, _context) do diff --git a/lib/ash_hq_web/core_components.ex b/lib/ash_hq_web/core_components.ex deleted file mode 100644 index 8b13789..0000000 --- a/lib/ash_hq_web/core_components.ex +++ /dev/null @@ -1 +0,0 @@ - diff --git a/mix.lock b/mix.lock index 05117c8..fb49b1d 100644 --- a/mix.lock +++ b/mix.lock @@ -5,7 +5,7 @@ "appsignal_phoenix": {:hex, :appsignal_phoenix, "2.3.5", "f2182960b1d51ca191baf96d977bc81032d6a8c0cde9be8802d8d47bb8f6d7d3", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:appsignal_plug, ">= 2.0.15 and < 3.0.0", [hex: :appsignal_plug, repo: "hexpm", optional: false]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.9", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0493a01077b75d14f46798f4b57007a19bfb79c51ff06a4e389ff1c1aa0bf5cf"}, "appsignal_plug": {:hex, :appsignal_plug, "2.0.15", "758a8a78944878e8461bbc77ca86219121a56f4299c6d79940ab083cf9afea00", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:plug, ">= 1.1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1c6059049e2081e808aaef04e2b9917e06277f61a35a0e103db860d08cbc41f1"}, "ash": {:hex, :ash, "3.0.0-rc.7", "f72a64fba1acdce7016984fe9cdf5e3ed856939fb14611d0c168e9971fe9bbed", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.8", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.7 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b6edc89cd39ec68bd765bfea271df011b20ab86f181cfab59ef6159e3a1577b4"}, - "ash_admin": {:hex, :ash_admin, "0.10.10-rc.0", "01a7f0e042c1529d955cd4d09a1c4e72c91bc72efdeb7fdb7a20897a9633c8aa", [:mix], [{:ash, "~> 3.0.0-rc.0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_phoenix, "~> 2.0-rc.0", [hex: :ash_phoenix, repo: "hexpm", optional: false]}, {:ash_postgres, "~> 2.0-rc.0", [hex: :ash_postgres, repo: "hexpm", optional: false]}, {:gettext, "~> 0.20", [hex: :gettext, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:tails, "~> 0.1", [hex: :tails, repo: "hexpm", optional: false]}], "hexpm", "acd01523bf3089a26169d7699030c3810e2fd5bdd1fc6191003d264c710f4fc6"}, + "ash_admin": {:hex, :ash_admin, "0.10.10-rc.1", "504089c1c2417034d4c5f1305da5d4270039d82ff44d762153cd217f9a714116", [:mix], [{:ash, "~> 3.0.0-rc.0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_phoenix, "~> 2.0-rc.0", [hex: :ash_phoenix, repo: "hexpm", optional: false]}, {:gettext, "~> 0.20", [hex: :gettext, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.7", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:tails, "~> 0.1", [hex: :tails, repo: "hexpm", optional: false]}], "hexpm", "2522f151c15fa7f60aedc1b6256e4e70178ed15ce20787ae989aebbdea498dfd"}, "ash_appsignal": {:hex, :ash_appsignal, "0.1.2", "a6eb1927a13c11006aad0d9ffaa011143344dd04c9b07ab94f459498b8ddc6d4", [:mix], [{:appsignal, "~> 2.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:ash, ">= 2.14.14", [hex: :ash, repo: "hexpm", optional: false]}], "hexpm", "dae3158337d2a36b76f04519ebe6d08ef5296823831993cef6069eeb879c5b94"}, "ash_blog": {:git, "https://github.com/ash-project/ash_blog.git", "d65161ba519f977c82f8cb45df160b079f357c7e", []}, "ash_csv": {:hex, :ash_csv, "0.9.7-rc.0", "b7b2528851b408f7fefea45165e04b1e52e754cea90d0bf27e1ad0b39bfc26cb", [:mix], [{:ash, "~> 3.0.0-rc.0", [hex: :ash, repo: "hexpm", optional: false]}, {:csv, "~> 3.0", [hex: :csv, repo: "hexpm", optional: false]}], "hexpm", "77233b3fcbdceafe1a18e8cd515f6dd91653e470f381d837196f0cf41ea8546e"}, diff --git a/priv/repo/migrations/20240403011834_install_5_extensions.exs b/priv/repo/migrations/20240403011834_install_5_extensions.exs new file mode 100644 index 0000000..3f6044c --- /dev/null +++ b/priv/repo/migrations/20240403011834_install_5_extensions.exs @@ -0,0 +1,27 @@ +defmodule AshHq.Repo.Migrations.Install5Extensions20240403011833 do + @moduledoc """ + Installs any extensions that are mentioned in the repo's `installed_extensions/0` callback + + This file was autogenerated with `mix ash_postgres.generate_migrations` + """ + + use Ecto.Migration + + def up do + execute("CREATE EXTENSION IF NOT EXISTS \"pg_trgm\"") + execute("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"") + execute("CREATE EXTENSION IF NOT EXISTS \"citext\"") + execute("CREATE EXTENSION IF NOT EXISTS \"pg_stat_statements\"") + execute("CREATE EXTENSION IF NOT EXISTS \"sslinfo\"") + end + + def down do + # Uncomment this if you actually want to uninstall the extensions + # when this migration is rolled back: + # execute("DROP EXTENSION IF EXISTS \"pg_trgm\"") + # execute("DROP EXTENSION IF EXISTS \"uuid-ossp\"") + # execute("DROP EXTENSION IF EXISTS \"citext\"") + # execute("DROP EXTENSION IF EXISTS \"pg_stat_statements\"") + # execute("DROP EXTENSION IF EXISTS \"sslinfo\"") + end +end diff --git a/priv/resource_snapshots/repo/extensions.json b/priv/resource_snapshots/repo/extensions.json new file mode 100644 index 0000000..cc57eeb --- /dev/null +++ b/priv/resource_snapshots/repo/extensions.json @@ -0,0 +1,9 @@ +{ + "installed": [ + "pg_trgm", + "uuid-ossp", + "citext", + "pg_stat_statements", + "sslinfo" + ] +} \ No newline at end of file diff --git a/test/live/settings_test.exs b/test/live/settings_test.exs deleted file mode 100644 index eed52ed..0000000 --- a/test/live/settings_test.exs +++ /dev/null @@ -1,122 +0,0 @@ -defmodule AshHq.SettingsTest do - use AshHqWeb.ConnCase - - import Phoenix.ConnTest - import Phoenix.LiveViewTest - - @endpoint AshHqWeb.Endpoint - - setup :register_and_log_in_user - - describe "change email form" do - test "renders", %{conn: conn} do - {:ok, _view, html} = live(conn, "/users/settings") - - assert html =~ "Update Email" - end - - test "submission shows a flash message", %{conn: conn} do - {:ok, view, _html} = live(conn, "/users/settings") - - assert {:ok, _view, html} = - view - |> element("form#update_email") - |> render_submit(%{ - update_email: %{email: "new_email@example.com", current_password: "password123"} - }) - |> follow_redirect(conn) - - assert html =~ "Check your email" - end - - test "submission sends an email but does not change the email", %{conn: conn, user: user} do - {:ok, view, _html} = live(conn, "/users/settings") - - view - |> element("form#update_email") - |> render_submit(%{ - update_email: %{email: "new_email@example.com", current_password: "password123"} - }) - - assert_received {:email, email} - - assert email.subject == "Confirm Your Email Change" - new_user = AshHq.Accounts.reload!(user, authorize?: false) - assert new_user.email == user.email - end - - test "following the link in the email changes the email", %{conn: conn, user: user} do - {:ok, view, _html} = live(conn, "/users/settings") - - view - |> element("form#update_email") - |> render_submit(%{ - update_email: %{email: "new_email@example.com", current_password: "password123"} - }) - - assert_received {:email, email} - - assert %{"url" => url} = Regex.named_captures(~r/(?http[^\s\"]*)/, email.html_body) - - uri = URI.parse(url) - - path = %{uri | authority: nil, host: nil, scheme: nil, port: nil} |> to_string() - - assert {:ok, _conn} = conn |> live(path) |> follow_redirect(conn, "/") - - new_user = AshHq.Accounts.reload!(user, authorize?: false) - assert to_string(new_user.email) == "new_email@example.com" - end - end - - describe "change_password" do - test "renders", %{conn: conn} do - {:ok, _view, html} = live(conn, "/users/settings") - - assert html =~ "Change Password" - end - - test "submission shows a flash message", %{conn: conn} do - {:ok, view, _html} = live(conn, "/users/settings") - - assert {:ok, _view, html} = - view - |> element("form#change_password") - |> render_submit(%{ - change_password: %{ - password: "hello world2!", - password_confirmation: "hello world2!", - current_password: "password123" - } - }) - |> follow_redirect(conn) - - assert html =~ "Password has been successfully changed" - end - - test "submission changes the password", %{conn: conn, user: user} do - {:ok, view, _html} = live(conn, "/users/settings") - - assert {:ok, _view, html} = - view - |> element("form#change_password") - |> render_submit(%{ - change_password: %{ - password: "hello world2!", - password_confirmation: "hello world2!", - current_password: "password123" - } - }) - |> follow_redirect(conn) - - assert html =~ "Password has been successfully changed" - - assert AshHq.Accounts.User - |> Ash.Query.for_read(:sign_in_with_password, %{ - email: user.email, - password: "hello world2!" - }) - |> AshHq.Accounts.read_one!(authorize?: false) - end - end -end