Skip to content

Commit

Permalink
fix(Stops.RouteStop): omit shuttle connections (#1775)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen authored Oct 20, 2023
1 parent b7f89b3 commit 0f55d33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/stops/lib/route_stop.ex
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ defmodule Stops.RouteStop do
|> Map.get(:id)
|> Routes.Repo.by_stop(include: "stop.connecting_stops")
|> Enum.reject(&(&1.id == route_stop.route.id))
|> Enum.reject(&(&1.description == :rail_replacement_bus))

%{route_stop | connections: connections}
end
Expand Down
23 changes: 19 additions & 4 deletions apps/stops/test/route_stop_test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
defmodule Stops.RouteStopTest do
use ExUnit.Case, async: true
use ExUnit.Case, async: false

import Stops.RouteStop
import Mock
alias Routes.{Route, Shape}
alias RoutePatterns.RoutePattern
alias Stops.{RouteStop, Stop}
Expand Down Expand Up @@ -618,9 +619,23 @@ defmodule Stops.RouteStopTest do
test "builds a list of connecting routes at a stop" do
route_stop = build_route_stop(@stop, @red_route)
assert route_stop.connections == {:error, :not_fetched}
fetched = fetch_connections(route_stop)
assert [%Route{} | _] = fetched.connections
assert Enum.find(fetched.connections, &(&1.id == fetched.route.id)) == nil
stop_id = @stop.id

with_mock(Routes.Repo,
by_stop: fn ^stop_id, [include: "stop.connecting_stops"] ->
[
%Route{id: @red_route.id},
%Route{id: "one", type: 2},
%Route{id: "another", type: 3},
%Route{id: "shuttle", description: :rail_replacement_bus, type: 3}
]
end
) do
fetched = fetch_connections(route_stop)
assert [%Route{}, %Route{}] = fetched.connections
assert Enum.find(fetched.connections, &(&1.id == fetched.route.id)) == nil
assert Enum.find(fetched.connections, &(&1.description == :rail_replacement_bus)) == nil
end
end
end

Expand Down

0 comments on commit 0f55d33

Please sign in to comment.