Skip to content

Commit

Permalink
Fix related link text for all modes (#2165)
Browse files Browse the repository at this point in the history
* related link text

* test
  • Loading branch information
anthonyshull authored Aug 29, 2024
1 parent c7800be commit 0258dd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions lib/dotcom/trip_plan/related_link.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,20 @@ defmodule Dotcom.TripPlan.RelatedLink do

defp route_link(route, trip_id, itinerary) do
icon_name = Route.icon_atom(route)

base_text =
if Route.type_atom(route) == :bus do
["Route ", route.name]
else
route.name
end

date = Date.to_iso8601(itinerary.start)
url = schedule_path(DotcomWeb.Endpoint, :show, route, date: date, trip: trip_id)
new([base_text, " schedules"], url, icon_name)

route
|> link_text()
|> new(url, icon_name)
end

defp link_text(%Route{type: 3} = route) do
"#{route.name} Bus schedules"
end

defp link_text(route) do
"#{route.long_name} schedules"
end

defp fare_links(itinerary) do
Expand Down
4 changes: 2 additions & 2 deletions test/dotcom/trip_plan/related_link_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ defmodule Dotcom.TripPlan.RelatedLinkTest do
assert fare_link.text == "View fare information"

if route.type == 3 do
assert text(route_link) == "Route #{route.name} schedules"
assert text(route_link) == "#{route.name} Bus schedules"
else
assert text(route_link) == "#{route.name} schedules"
assert text(route_link) == "#{route.long_name} schedules"
end

case route.type do
Expand Down

0 comments on commit 0258dd1

Please sign in to comment.