Skip to content

Commit 4d3def7

Browse files
committed
check for __live__/0 when validating routes
fixes warnings when running tests on phoenix main
1 parent b59bede commit 4d3def7

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

lib/phoenix_live_view/router.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ defmodule Phoenix.LiveView.Router do
419419
metadata =
420420
metadata
421421
|> Map.put(:phoenix_live_view, {live_view, action, opts, live_session})
422-
|> Map.put(:mfa, {live_view, :mount, 3})
422+
|> Map.put(:mfa, {live_view, :__live__, 0})
423423
|> Map.put(:log_module, live_view)
424424

425425
{as_action,

test/support/live_views/general.ex

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,29 @@ defmodule Phoenix.LiveViewTest.Support.StartAsyncLive.LC do
874874
{:noreply, socket |> put_flash(:info, flash) |> push_navigate(to: "/start_async?test=ok")}
875875
end
876876
end
877+
878+
# empty, but needed to silence warnings about unavailable modules
879+
defmodule Phoenix.LiveViewTest.Support.FooBarLive do
880+
use Phoenix.LiveView
881+
def render(assigns), do: ~H""
882+
end
883+
884+
defmodule Phoenix.LiveViewTest.Support.FooBarLive.Index do
885+
use Phoenix.LiveView
886+
def render(assigns), do: ~H""
887+
end
888+
889+
defmodule Phoenix.LiveViewTest.Support.FooBarLive.Nested.Index do
890+
use Phoenix.LiveView
891+
def render(assigns), do: ~H""
892+
end
893+
894+
defmodule Phoenix.LiveViewTest.Support.Live.Nested.Module do
895+
use Phoenix.LiveView
896+
def render(assigns), do: ~H""
897+
end
898+
899+
defmodule Phoenix.LiveViewTest.Support.NoSuffix do
900+
use Phoenix.LiveView
901+
def render(assigns), do: ~H""
902+
end

test/support/router.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ defmodule Phoenix.LiveViewTest.Support.Router do
3131
live "/clock", ClockLive
3232
live "/redir", RedirLive
3333
live "/elements", ElementsLive
34-
live "/inner_block", InnerLive
3534

3635
live "/render-with", RenderWithLive
3736
live "/same-child", SameChildLive
@@ -67,7 +66,7 @@ defmodule Phoenix.LiveViewTest.Support.Router do
6766
live "/router/foobarbaz/nested/index", FooBarLive.Nested.Index, :index
6867
live "/router/foobarbaz/nested/show", FooBarLive.Nested.Index, :show
6968
live "/router/foobarbaz/custom", FooBarLive, :index, as: :custom_foo_bar
70-
live "/router/foobarbaz/with_live", Phoenix.LiveViewTest.Support.Live.Nested.Module, :action
69+
live "/router/foobarbaz/with_live", Live.Nested.Module, :action
7170
live "/router/foobarbaz/nosuffix", NoSuffix, :index, as: :custom_route
7271

7372
# integration layout
@@ -115,7 +114,6 @@ defmodule Phoenix.LiveViewTest.Support.Router do
115114
# integration lifecycle
116115
live "/lifecycle", HooksLive
117116
live "/lifecycle/bad-mount", HooksLive.BadMount
118-
live "/lifecycle/own-mount", HooksLive.OwnMount
119117
live "/lifecycle/halt-mount", HooksLive.HaltMount
120118
live "/lifecycle/redirect-cont-mount", HooksLive.RedirectMount, :cont
121119
live "/lifecycle/redirect-halt-mount", HooksLive.RedirectMount, :halt

0 commit comments

Comments
 (0)