Skip to content

Commit 5db86e2

Browse files
committed
fix existing tests
1 parent f13ff3a commit 5db86e2

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

lib/phoenix_live_view/channel.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ defmodule Phoenix.LiveView.Channel do
476476

477477
Process.send_after(self(), {@prefix, :adoption_timeout}, timeout)
478478

479-
{:reply, {:ok, Diff.to_iodata(diff)}, {:adoptable, state}}
479+
# TODO: check if we can avoid sending the assigns back
480+
{:reply, {:ok, Diff.to_iodata(diff), socket.assigns}, {:adoptable, state}}
480481

481482
{:stop, socket} ->
482483
{:stop, :shutdown, {:stop, socket}, nil}

lib/phoenix_live_view/controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ defmodule Phoenix.LiveView.Controller do
3737
"""
3838
def live_render(%Plug.Conn{} = conn, view, opts \\ []) do
3939
case LiveView.Static.render(conn, view, opts) do
40-
{:ok, content} ->
40+
{:ok, content, socket_assigns} ->
4141
conn
4242
|> Plug.Conn.fetch_query_params()
4343
|> ensure_format()
4444
|> Phoenix.Controller.put_view(LiveView.Static)
4545
|> Phoenix.Controller.render(
4646
:template,
47-
%{content: content}
47+
Map.merge(socket_assigns, %{content: content, live_module: view})
4848
)
4949

5050
{:stop, %Socket{redirected: {:redirect, %{status: status} = opts}} = socket} ->

lib/phoenix_live_view/static.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ defmodule Phoenix.LiveView.Static do
174174
]
175175

176176
try do
177-
{:ok, to_rendered_content_tag(socket, tag, view, attrs)}
177+
{:ok, to_rendered_content_tag(socket, tag, view, attrs), socket.assigns}
178178
catch
179179
:throw, {:phoenix, :child_redirect, redirected, flash} ->
180180
{:stop, Utils.replace_flash(%{socket | redirected: redirected}, flash)}
@@ -210,7 +210,7 @@ defmodule Phoenix.LiveView.Static do
210210
)
211211

212212
# TODO: handle call timeout
213-
with {:ok, iodata} <- GenServer.call(pid, {:phoenix, :disconnected_adoptable_render}) do
213+
with {:ok, iodata, assigns} <- GenServer.call(pid, {:phoenix, :disconnected_adoptable_render}) do
214214
data_attrs = [
215215
phx_session: sign_root_session(socket, router, view, to_sign_session, live_session),
216216
phx_static: sign_static_token(socket),
@@ -225,7 +225,9 @@ defmodule Phoenix.LiveView.Static do
225225
| extended_attrs
226226
]
227227

228-
{:ok, content_tag(tag, attrs, iodata)}
228+
# TODO: we currently expect the socket assigns for LiveViewTest
229+
# check if we can aboid copying assigns...
230+
{:ok, content_tag(tag, attrs, iodata), assigns}
229231
end
230232
end
231233
end

0 commit comments

Comments
 (0)