diff --git a/test/arrow_web/controllers/disruption_v2_controller_test.exs b/test/arrow_web/controllers/disruption_v2_controller_test.exs index daadf73b..d3476311 100644 --- a/test/arrow_web/controllers/disruption_v2_controller_test.exs +++ b/test/arrow_web/controllers/disruption_v2_controller_test.exs @@ -66,13 +66,13 @@ defmodule ArrowWeb.DisruptionV2ControllerTest do @tag :authenticated test "lists disruptions that match a search query on title", %{conn: conn} do - route = insert(:gtfs_route) # Use insert to get a route with a unique ID - + route = insert(:gtfs_route) + insert(:limit, disruption: build(:disruption_v2, title: "Test disruption Alpha"), route: route ) - + insert(:limit, disruption: build(:disruption_v2, title: "Test disruption Beta"), route: route @@ -86,10 +86,11 @@ defmodule ArrowWeb.DisruptionV2ControllerTest do @tag :authenticated test "lists disruptions that match a search query on stop names", %{conn: conn} do - route = insert(:gtfs_route) # Use insert to get a route with a unique ID + # Use insert to get a route with a unique ID + route = insert(:gtfs_route) start_stop = insert(:gtfs_stop, name: "UniqueStopName Station") end_stop = insert(:gtfs_stop, name: "Regular Station") - + # Disruption that should match the search insert(:limit, disruption: build(:disruption_v2, title: "First Disruption"), @@ -97,7 +98,7 @@ defmodule ArrowWeb.DisruptionV2ControllerTest do start_stop: start_stop, end_stop: end_stop ) - + # Disruption that shouldn't match the search insert(:limit, disruption: build(:disruption_v2, title: "Second Disruption"), @@ -114,21 +115,24 @@ defmodule ArrowWeb.DisruptionV2ControllerTest do test "lists disruptions that match a search query on shuttle names", %{conn: conn} do # Create a route to be used by both the shuttle and the limits route = insert(:gtfs_route) - + disruption_with_shuttle = insert(:disruption_v2, title: "Shuttle Disruption") disruption_without_shuttle = insert(:disruption_v2, title: "Regular Disruption") - + # Create a shuttle with proper association to the route, and include stops AND times to next stop - shuttle = Arrow.ShuttlesFixtures.shuttle_fixture( - %{ - shuttle_name: "SpecialShuttleName Bus", - disrupted_route_id: route.id, - status: :active - }, - true, # include stops parameter - true # include times to next stop parameter - this was missing - ) - + shuttle = + Arrow.ShuttlesFixtures.shuttle_fixture( + %{ + shuttle_name: "SpecialShuttleName Bus", + disrupted_route_id: route.id, + status: :active + }, + # include stops parameter + true, + # include times to next stop parameter - this was missing + true + ) + # Use the fixture to create the replacement service instead of raw insert Arrow.DisruptionsFixtures.replacement_service_fixture(%{ disruption_id: disruption_with_shuttle.id, @@ -136,7 +140,7 @@ defmodule ArrowWeb.DisruptionV2ControllerTest do start_date: ~D[2023-01-01], end_date: ~D[2023-12-31] }) - + # Add limits to both disruptions using the same route insert(:limit, disruption: disruption_with_shuttle, route: route) insert(:limit, disruption: disruption_without_shuttle, route: route) @@ -161,13 +165,14 @@ defmodule ArrowWeb.DisruptionV2ControllerTest do @tag :authenticated test "empty search string returns all disruptions", %{conn: conn} do - route = insert(:gtfs_route) # Use insert to get a route with a unique ID - + # Use insert to get a route with a unique ID + route = insert(:gtfs_route) + insert(:limit, disruption: build(:disruption_v2, title: "First Disruption"), route: route ) - + insert(:limit, disruption: build(:disruption_v2, title: "Second Disruption"), route: route