Skip to content

Commit

Permalink
Merge branch 'apb/error-pages' of https://github.com/BeaconCMS/beacon
Browse files Browse the repository at this point in the history
…into apb/error-pages
  • Loading branch information
APB9785 committed Sep 22, 2023
2 parents a08de10 + b38f90d commit 8324828
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/beacon/loader/error_module_loader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ defmodule Beacon.Loader.ErrorModuleLoader do
end

:ok = Loader.reload_module!(error_module, ast)

{:ok, error_module, ast}
end

Expand Down
17 changes: 17 additions & 0 deletions test/beacon/loader/error_module_loader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defmodule Beacon.Loader.ErrorModuleLoaderTest do
end

setup %{conn: conn} do
component_fixture(site: @site)
:ok = Beacon.Loader.populate_layouts(@site)
:ok = Beacon.Loader.populate_error_pages(@site)
error_module = load_error_pages_module(@site)
Expand Down Expand Up @@ -69,6 +70,22 @@ defmodule Beacon.Loader.ErrorModuleLoaderTest do
assert error_module.layout(501, %{inner_content: error_page.template}) == {:safe, ["#custom_layout#", "error_501"]}
end

test "user-defined component in layout" do

Check failure on line 73 in test/beacon/loader/error_module_loader_test.exs

View workflow job for this annotation

GitHub Actions / test (OTP 23 | Elixir 1.13.0)

test user-defined component in layout (Beacon.Loader.ErrorModuleLoaderTest)

Check failure on line 73 in test/beacon/loader/error_module_loader_test.exs

View workflow job for this annotation

GitHub Actions / test (OTP 26 | Elixir 1.15.1)

test user-defined component in layout (Beacon.Loader.ErrorModuleLoaderTest)
layout = published_layout_fixture(template: ~S|<%= my_component("sample_component", val: 1 )%><%= @inner_content %>|, site: @site)
error_page = error_page_fixture(layout: layout, template: "error", status: 502, site: @site)
error_module = load_error_pages_module(@site)

assert error_module.layout(502, %{inner_content: error_page.template}) == {:safe, ["1", "error"]}
end

test "user-defined component in page" do

Check failure on line 81 in test/beacon/loader/error_module_loader_test.exs

View workflow job for this annotation

GitHub Actions / test (OTP 23 | Elixir 1.13.0)

test user-defined component in page (Beacon.Loader.ErrorModuleLoaderTest)

Check failure on line 81 in test/beacon/loader/error_module_loader_test.exs

View workflow job for this annotation

GitHub Actions / test (OTP 26 | Elixir 1.15.1)

test user-defined component in page (Beacon.Loader.ErrorModuleLoaderTest)
layout = published_layout_fixture(template: ~S|<%= @inner_content %>|, site: @site)
error_page = error_page_fixture(layout: layout, template: ~S|<%= my_component("sample_component", val: 1) %>|, status: 503, site: @site)
error_module = load_error_pages_module(@site)

assert error_module.layout(503, %{inner_content: error_page.template}) == {:safe, ["1", "error"]}
end

test "default error pages", %{conn: conn, error_module: error_module} do
expected =
~S"""
Expand Down

0 comments on commit 8324828

Please sign in to comment.