Skip to content

Commit

Permalink
refactor: rename erroneous references to shuttle_route
Browse files Browse the repository at this point in the history
  • Loading branch information
lemald committed Nov 6, 2024
1 parent c257770 commit fff413d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/arrow_web/live/shuttle_live/shuttle_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule ArrowWeb.ShuttleViewLive do
<.simple_form
:let={f}
for={@form}
as={:shuttle_route}
as={:shuttle}
action={@http_action}
phx-submit={@action}
id="shuttle-form"
Expand Down Expand Up @@ -120,7 +120,7 @@ defmodule ArrowWeb.ShuttleViewLive do
|> assign(:form, form)
|> assign(:form_action, "edit")
|> assign(:http_action, ~p"/shuttles/#{id}")
|> assign(:shuttle_route, shuttle)
|> assign(:shuttle, shuttle)
|> assign(:title, "edit shuttle")
|> assign(:gtfs_disruptable_routes, gtfs_disruptable_routes)
|> assign(:shapes, shapes)
Expand Down Expand Up @@ -155,17 +155,17 @@ defmodule ArrowWeb.ShuttleViewLive do
{:ok, socket}
end

def handle_event("validate", %{"shuttle_route" => shuttle_route_params}, socket) do
def handle_event("validate", %{"shuttle" => shuttle_params}, socket) do
form =
%Shuttle{} |> Shuttles.change_shuttle(shuttle_route_params) |> to_form(action: :validate)
%Shuttle{} |> Shuttles.change_shuttle(shuttle_params) |> to_form(action: :validate)

{:noreply, assign(socket, form: form)}
end

def handle_event("edit", %{"shuttle_route" => shuttle_route_params}, socket) do
shuttle = Shuttles.get_shuttle!(socket.assigns.shuttle_route.id)
def handle_event("edit", %{"shuttle" => shuttle_params}, socket) do
shuttle = Shuttles.get_shuttle!(socket.assigns.shuttle.id)

case Arrow.Shuttles.update_shuttle(shuttle, shuttle_route_params) do
case Arrow.Shuttles.update_shuttle(shuttle, shuttle_params) do
{:ok, shuttle} ->
{:noreply,
socket
Expand All @@ -177,8 +177,8 @@ defmodule ArrowWeb.ShuttleViewLive do
end
end

def handle_event("create", %{"shuttle_route" => shuttle_route_params}, socket) do
case Arrow.Shuttles.create_shuttle(shuttle_route_params) do
def handle_event("create", %{"shuttle" => shuttle_params}, socket) do
case Arrow.Shuttles.create_shuttle(shuttle_params) do
{:ok, shuttle} ->
{:noreply,
socket
Expand Down
8 changes: 4 additions & 4 deletions test/arrow_web/live/shuttle_live/shuttle_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ defmodule ArrowWeb.ShuttleLiveTest do

{:ok, conn} =
new_live
|> form("#shuttle-form", shuttle_route: @create_attrs)
|> form("#shuttle-form", shuttle: @create_attrs)
|> render_submit()
|> follow_redirect(conn)

Expand All @@ -90,7 +90,7 @@ defmodule ArrowWeb.ShuttleLiveTest do
test "renders errors when data is invalid", %{conn: conn} do
{:ok, new_live, _html} = live(conn, ~p"/shuttles/new")

assert new_live |> form("#shuttle-form", shuttle_route: @invalid_attrs) |> render_submit() =~
assert new_live |> form("#shuttle-form", shuttle: @invalid_attrs) |> render_submit() =~
"can&#39;t be blank"
end
end
Expand All @@ -104,7 +104,7 @@ defmodule ArrowWeb.ShuttleLiveTest do

{:ok, conn} =
edit_live
|> form("#shuttle-form", shuttle_route: @update_attrs)
|> form("#shuttle-form", shuttle: @update_attrs)
|> render_submit()
|> follow_redirect(conn)

Expand All @@ -115,7 +115,7 @@ defmodule ArrowWeb.ShuttleLiveTest do
test "renders errors when data is invalid", %{conn: conn, shuttle: shuttle} do
{:ok, new_live, _html} = live(conn, ~p"/shuttles/#{shuttle}/edit")

assert new_live |> form("#shuttle-form", shuttle_route: @invalid_attrs) |> render_submit() =~
assert new_live |> form("#shuttle-form", shuttle: @invalid_attrs) |> render_submit() =~
"can&#39;t be blank"
end
end
Expand Down

0 comments on commit fff413d

Please sign in to comment.