diff --git a/app/controllers/admin/configs_controller.rb b/app/controllers/admin/configs_controller.rb index ab8db5963..5ef0970b8 100644 --- a/app/controllers/admin/configs_controller.rb +++ b/app/controllers/admin/configs_controller.rb @@ -13,9 +13,12 @@ class Admin::ConfigsController < Admin::AdminController helper_method :build_dashboard_mode_collection PERMITTED_CONFIGS = [ + :application_title, :open_trip_planner, :open_trip_planner_version, :otp_itinerary_quantity, + :otp_car_park_quantity, + :otp_transit_quantity, :otp_paratransit_quantity, # :otp_max_itineraries_shown, :tff_api_key, diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index b11655fa0..a80908484 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -48,17 +48,16 @@ def user_trip_email(addresses, trip, itinerary=nil) @trip = trip @traveler = trip.user @locale = @traveler.locale.try(:name) - subject = "FindMyRidePA Trip Details sent to you by traveler's request" + subject = [application_title, "Trip Details sent to you by traveler's request"].compact.join(" ") @itinerary = itinerary || @trip.selected_itinerary unless @itinerary return end - if @itinerary.service and @itinerary.service.logo.url - attachments.inline['service_logo.png'] = open(ActionController::Base.helpers.asset_path(@itinerary.service.logo.thumb.url.to_s), 'rb').read - end - map_image = MapService.new(@itinerary).create_static_map - attachments.inline[@itinerary.id.to_s + ".png"] = open(map_image, 'rb').read + + attach_service_logo + attach_map_image attach_standard_icons #TODO: Don't attach all icons by default. Attach them as needed. + mail(to: addresses, subject: subject) end @@ -112,7 +111,7 @@ def api_v2_reset_password_instructions(user, new_password) def ecolane_trip_email(addresses, bookings) @decorated_bookings = bookings # form [[booking, trip_hash],...] - subject = "FindMyRidePA Trip Details sent to you by traveler's request" + subject = [application_title, "Trip Details sent to you by traveler's request"].compact.join(" ") mail(to: addresses, subject: subject) end @@ -121,17 +120,16 @@ def user_trip_reminder(addresses,trip,days_away) @trip = trip @traveler = @trip.user @locale = @traveler.locale.try(:name) - subject = "FindMyRidePA Trip Reminder!" + subject = [application_title, "Trip Reminder!"].compact.join(" ") @itinerary = @trip.selected_itinerary unless @itinerary return end - if @itinerary.service and @itinerary.service.logo.url - attachments.inline['service_logo.png'] = open(ActionController::Base.helpers.asset_path(@itinerary.service.logo.thumb.url.to_s), 'rb').read - end - map_image = MapService.new(@itinerary).create_static_map - attachments.inline[@itinerary.id.to_s + ".png"] = open(map_image, 'rb').read + + attach_service_logo + attach_map_image attach_standard_icons #TODO: Don't attach all icons by default. Attach them as needed. + mail(to: addresses, subject: subject) end @@ -145,6 +143,31 @@ def attach_standard_icons end end + def attach_service_logo + if @itinerary.service and @itinerary.service.logo.url.present? + begin + attachments.inline['service_logo.png'] = open(ActionController::Base.helpers.asset_path(@itinerary.service.logo.thumb.url.to_s), 'rb').read + rescue Errno::ENOENT + Rails.logger.error "Failure to attach logo to email: '#{@itinerary.service.logo.thumb.url.to_s}' is not a valid path for a logo." + rescue StandardError => e + Rails.logger.error e + end + end + end + + def attach_map_image + if ENV['GOOGLE_API_KEY'].present? + begin + map_image = MapService.new(@itinerary).create_static_map + attachments.inline[@itinerary.id.to_s + ".png"] = open(map_image, 'rb').read + rescue StandardError => e + Rails.logger.error e + end + end + end + def application_title + Config.application_title.present? ? Config.application_title : nil + end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 4574cf05f..15cd3fa87 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -123,6 +123,11 @@ def initialize(user) can :manage, GeographyRecord # Can create Geography records can :manage, Role, # Can manage roles for current agency resource_id: user.staff_agency.id + # Admins cannot manage superusers + cannot :manage, User, # Cannot manage superusers + id: User.all.superuser.pluck(:id) + cannot :manage, Role, # Cannot manage superuser Roles + id: Role.find_by(name: :superuser) # Transportation Admin Permissions if user.transportation_admin? @@ -160,16 +165,16 @@ def initialize(user) can :manage, BookingWindow, agency_id: user.staff_agency.agency_oversight_agency.pluck(:transportation_agency_id).concat([user.staff_agency.id]) can :manage, Service, - id: user.get_services_for_oversight.pluck(:id).concat(Service.no_agencies_assigned.pluck(:id)) # Can access services associated with an oversight agency, and those with no oversight agency + id: user.get_services_for_oversight.pluck(:id).concat(Service.no_agencies_assigned.pluck(:id)) # Can access services associated with an oversight agency, and those with no oversight agency can :manage, Role # Can manage Roles # Mapping related permissions can :manage, GeographyRecord # Can manage geography records # Oversight Admins cannot manage superusers cannot :manage, User, # Cannot manage superusers - id: User.all.superuser.pluck(:id) + id: User.all.superuser.pluck(:id) cannot :manage, Role, # Cannot manage superuser Roles - id: Role.find_by(name: :superuser) + id: Role.find_by(name: :superuser) end end # end admin diff --git a/app/models/agency.rb b/app/models/agency.rb index 720795435..794b81e00 100644 --- a/app/models/agency.rb +++ b/app/models/agency.rb @@ -14,7 +14,7 @@ class Agency < ApplicationRecord ### SCOPES, CONSTANTS, & VALIDATIONS ### - validates :name, presence: true + validates :name, presence: true, uniqueness: true validates :agency_type_id, presence: true contact_fields email: :email, phone: :phone, url: :url @@ -29,7 +29,7 @@ class Agency < ApplicationRecord has_many :funding_sources, dependent: :destroy has_many :travel_patterns # this is to help access the Agency index page, although it's a bit redundant - has_one :agency_oversight_agency,foreign_key:"transportation_agency_id", dependent: :destroy + has_one :agency_oversight_agency, foreign_key: "transportation_agency_id", dependent: :destroy belongs_to :agency_type AGENCY_TYPE_MAP = { diff --git a/app/models/concerns/role_helper.rb b/app/models/concerns/role_helper.rb index b9cb6a391..330335b09 100644 --- a/app/models/concerns/role_helper.rb +++ b/app/models/concerns/role_helper.rb @@ -353,25 +353,25 @@ def get_travelers_for_staff_user def get_trips_for_staff_user # Conditional statement flow: - # If current user is a traveler => return nil - # If current user is a superuser => return all Trips - # If current user is a transportation agency staff => return Trips associated with the agency - # If current user is viewing as oversight staff => return Trips associated with all agencies under the oversight agency - # If current user is viewing as transportation agency staff => return Trips associated with the current transportation agency - # If the current user is viewing all unaffiliated trips and is oversight staff => return Trips associated with no tranpsortation agency + if self.superuser? + # If current user is a superuser => return all Trips Trip.all elsif self.transportation_admin? || self.transportation_staff? + # If current user is a transportation agency staff or admin => return Trips associated with the agency Trip.with_transportation_agency(self.staff_agency.id) elsif self.currently_oversight? + # If current user is viewing as oversight staff or admin => return Trips associated with all agencies under the oversight agency tas = AgencyOversightAgency.where(oversight_agency_id: self.staff_agency.id).pluck(:transportation_agency_id) Trip.with_transportation_agency(tas) elsif self.currently_transportation? - Trip.with_transportation_agency(self.current_agency.id) + # If current user is viewing as transportation agency staff or admin => return Trips associated with the current transportation agency + Trip.with_transportation_agency(self.current_agency.id) elsif self.staff_agency&.oversight? && self.current_agency.nil? + # If the current user is viewing all unaffiliated trips and is oversight staff => return Trips associated with no tranpsortation agency Trip.with_no_transportation_agency - # Fallback just in case an edge case is missed else + # If current user is a traveler => return nil nil end end diff --git a/app/models/config.rb b/app/models/config.rb index ee5004ceb..83118e9a2 100644 --- a/app/models/config.rb +++ b/app/models/config.rb @@ -22,8 +22,9 @@ class Config < ApplicationRecord DEFAULT_NOTIFICATION_PREFS = [7,3,1].freeze DEFAULT_CONFIGS = { + application_title: "", # (String) The title of the application. Mostly used in emails. bike_reluctance: 5, # (Integer) ??? - booking_api: 'all', # (String) Declares which booking apis services may use. Other values include "none" and the name of an api. + booking_api: "all", # (String) Declares which booking apis services may use. Other values include "none" and the name of an api. daily_scheduled_tasks: [], dashboard_mode: "default", # (String) Set to "travel_patterns" to enable the travel pattern workflow. dashboard_reports: [], # (Array) ??? @@ -34,8 +35,10 @@ class Config < ApplicationRecord maximum_booking_notice: 30, # (Integer) The maximum number of days into the future a user is allowed to book. max_walk_minutes: 45, # (Integer) The maximum number of minutes a traveler is expected to walk when planing a trip. open_trip_planner: "", # (String) OTP's base url. - open_trip_planner_version: 'v1', # (String) Which version of OTP to use. The other option is "v2". + open_trip_planner_version: "v1", # (String) Which version of OTP to use. The other option is "v2". otp_itinerary_quantity: 3, + otp_car_park_quantity: 3, + otp_transit_quantity: 3, otp_paratransit_quantity: 3, # otp_max_itineraries_shown: 3, require_user_confirmation: false, # (Boolean) Requires user to confirm their email address within a certain timeframe. diff --git a/app/models/trip.rb b/app/models/trip.rb index 29dc350b4..f227fb8fe 100644 --- a/app/models/trip.rb +++ b/app/models/trip.rb @@ -44,6 +44,7 @@ class Trip < ApplicationRecord TRIP_TYPES = [ :transit, :paratransit, + # :car_park, # This trip type is not selectable. Instead, it is automatically included when both :car and :transit are selected :taxi, :walk, :car, diff --git a/app/services/external_api_ambassadors/otp.rb b/app/services/external_api_ambassadors/otp.rb index d2ab952a3..21f1d96cf 100644 --- a/app/services/external_api_ambassadors/otp.rb +++ b/app/services/external_api_ambassadors/otp.rb @@ -193,20 +193,21 @@ def get_stoptimes trip_id, agency_id=1 return JSON.parse(resp.body) end - def get_otp_mode trip_type - hash = {'transit': 'TRANSIT,WALK', - 'bicycle_transit': 'TRANSIT,BICYCLE', - 'park_transit':'CAR_PARK,WALK,TRANSIT', - 'car_transit':'CAR,WALK,TRANSIT', - 'bike_park_transit':'BICYCLE_PARK,WALK,TRANSIT', - 'paratransit':'TRANSIT,WALK,FLEX_ACCESS,FLEX_EGRESS,FLEX_DIRECT', - 'rail':'TRAM,SUBWAY,RAIL,WALK', - 'bus':'BUS,WALK', - 'walk':'WALK', - 'car':'CAR', - 'bicycle':'BICYCLE'} - hash[trip_type.to_sym] - end + # Dead code? Drew Teter - 4/7/2023 + # def get_otp_mode trip_type + # hash = {'transit': 'TRANSIT,WALK', + # 'bicycle_transit': 'TRANSIT,BICYCLE', + # 'park_transit': 'CAR_PARK,WALK,TRANSIT', + # 'car_transit': 'CAR,WALK,TRANSIT', + # 'bike_park_transit': 'BICYCLE_PARK,WALK,TRANSIT', + # 'paratransit': 'TRANSIT,WALK,FLEX_ACCESS,FLEX_EGRESS,FLEX_DIRECT', + # 'rail': 'TRAM,SUBWAY,RAIL,WALK', + # 'bus': 'BUS,WALK', + # 'walk': 'WALK', + # 'car': 'CAR', + # 'bicycle': 'BICYCLE'} + # hash[trip_type.to_sym] + # end # Wraps a response body in an OTPResponse object for easy inspection and manipulation def unpack(response) diff --git a/app/services/external_api_ambassadors/otp_ambassador.rb b/app/services/external_api_ambassadors/otp_ambassador.rb index 7898d7de7..3af940b45 100644 --- a/app/services/external_api_ambassadors/otp_ambassador.rb +++ b/app/services/external_api_ambassadors/otp_ambassador.rb @@ -5,25 +5,27 @@ class OTPAmbassador # Translates 1-click trip_types into OTP mode requests TRIP_TYPE_DICTIONARY = { - transit: { label: :otp_transit, modes: "TRANSIT,WALK" }, - paratransit: { label: :otp_paratransit, modes: "CAR" }, - taxi: { label: :otp_car, modes: "CAR" }, - walk: { label: :otp_walk, modes: "WALK"}, - car: { label: :otp_car, modes: "CAR"}, - bicycle: { label: :otp_bicycle, modes: "BICYCLE"}, - uber: { label: :otp_car, modes: "CAR"}, - lyft: { label: :otp_car, modes: "CAR"} + transit: { label: :otp_transit, modes: "TRANSIT,WALK" }, + paratransit: { label: :otp_paratransit, modes: "CAR" }, + car_park: { label: :otp_car_park, modes: "" }, + taxi: { label: :otp_car, modes: "CAR" }, + walk: { label: :otp_walk, modes: "WALK" }, + car: { label: :otp_car, modes: "CAR" }, + bicycle: { label: :otp_bicycle, modes: "BICYCLE" }, + uber: { label: :otp_car, modes: "CAR" }, + lyft: { label: :otp_car, modes: "CAR" } } TRIP_TYPE_DICTIONARY_V2 = { - transit: { label: :otp_transit, modes: "CAR_PARK,TRANSIT,WALK" }, - paratransit: { label: :otp_paratransit, modes: "CAR_PARK,TRANSIT,WALK,FLEX_ACCESS,FLEX_EGRESS,FLEX_DIRECT" }, - taxi: { label: :otp_car, modes: "CAR" }, - walk: { label: :otp_walk, modes: "WALK"}, - car: { label: :otp_car, modes: "CAR"}, - bicycle: { label: :otp_bicycle, modes: "BICYCLE"}, - uber: { label: :otp_car, modes: "CAR"}, - lyft: { label: :otp_car, modes: "CAR"} + transit: { label: :otp_transit, modes: "TRANSIT,WALK" }, + paratransit: { label: :otp_paratransit, modes: "TRANSIT,WALK,FLEX_ACCESS,FLEX_EGRESS,FLEX_DIRECT" }, + car_park: { label: :otp_car_park, modes: "CAR_PARK,TRANSIT,WALK" }, + taxi: { label: :otp_car, modes: "CAR" }, + walk: { label: :otp_walk, modes: "WALK" }, + car: { label: :otp_car, modes: "CAR" }, + bicycle: { label: :otp_bicycle, modes: "BICYCLE" }, + uber: { label: :otp_car, modes: "CAR" }, + lyft: { label: :otp_car, modes: "CAR" } } # Initialize with a trip, an array of trip trips, an HTTP Request Bundler object, @@ -82,6 +84,7 @@ def get_duration(trip_type) return 0 if errors(trip_type) itineraries = ensure_response(trip_type).itineraries return itineraries[0]["duration"] if itineraries[0] + 0 end # Extracts a trip distance from the OTP response. @@ -89,6 +92,20 @@ def get_distance(trip_type) return 0 if errors(trip_type) itineraries = ensure_response(trip_type).itineraries return extract_distance(itineraries[0]) if itineraries[0] + 0 + end + + def max_itineraries(trip_type_label) + quantity_config = { + otp_car: Config.otp_itinerary_quantity, + otp_walk: Config.otp_itinerary_quantity, + otp_bicycle: Config.otp_itinerary_quantity, + otp_car_park: Config.otp_car_park_quantity, + otp_transit: Config.otp_transit_quantity, + otp_paratransit: Config.otp_paratransit_quantity + } + + quantity_config[trip_type_label] end # Dead Code? - Drew 02/16/2023 @@ -111,7 +128,7 @@ def prepare_http_requests # Formats the trip as an OTP request based on trip_type def format_trip_as_otp_request(trip_type) - num_itineraries = trip_type[:label] == :otp_paratransit ? Config.otp_paratransit_quantity : Config.otp_itinerary_quantity + num_itineraries = max_itineraries(trip_type[:label]) { from: [@trip.origin.lat, @trip.origin.lng], to: [@trip.destination.lat, @trip.destination.lng], @@ -142,8 +159,13 @@ def ensure_response(trip_type) # Converts an OTP itinerary hash into a set of 1-Click itinerary attributes def convert_itinerary(otp_itin, trip_type) associate_legs_with_services(otp_itin) + itin_has_invalid_leg = otp_itin.legs.detect{ |leg| + leg['serviceName'] && leg['serviceId'].nil? + } + return nil if itin_has_invalid_leg + service_id = otp_itin.legs - .detect{|leg| leg['serviceId'].present? } + .detect{ |leg| leg['serviceId'].present? } &.fetch('serviceId', nil) return { diff --git a/app/services/trip_planner.rb b/app/services/trip_planner.rb index be32a6fbc..a22d6b099 100644 --- a/app/services/trip_planner.rb +++ b/app/services/trip_planner.rb @@ -18,6 +18,8 @@ def initialize(trip, options={}) @trip = trip @options = options @trip_types = (options[:trip_types] || TRIP_TYPES) & TRIP_TYPES # Set to only valid trip_types, all by default + @trip_types.push(:car_park) if (@trip_types.include?(:car) && @trip_types.include?(:transit)) + @errors = [] @paratransit_drive_time_multiplier = 2.5 @master_service_scope = options[:available_services] || Service.all # Allow pre-filtering of available services @@ -183,6 +185,10 @@ def build_transit_itineraries build_fixed_itineraries :transit end + def build_car_park_itineraries + build_fixed_itineraries :car_park + end + # Builds walk itineraries, using OTP by default def build_walk_itineraries build_fixed_itineraries :walk @@ -256,7 +262,7 @@ def build_paratransit_itineraries .find_or_initialize_by( service_id: svc.id, trip_type: :paratransit, - trip_id: @trip.id, + trip_id: @trip.id ) # Whether an itinerary was found, or initialized, we need to update it diff --git a/app/views/admin/agencies/_edit_agency.html.haml b/app/views/admin/agencies/_edit_agency.html.haml index b07770ffd..057c857c9 100644 --- a/app/views/admin/agencies/_edit_agency.html.haml +++ b/app/views/admin/agencies/_edit_agency.html.haml @@ -34,7 +34,7 @@ - if !current_user.superuser? = foa.input :oversight_agency_id, disabled: !current_user.superuser?, - collection: [@agency.agency_oversight_agency.oversight_agency], + collection: [@agency.agency_oversight_agency&.oversight_agency].compact, label_method: :name, value_method: :id, include_blank: false, diff --git a/app/views/admin/configs/_miscellaneous.html.haml b/app/views/admin/configs/_miscellaneous.html.haml index 526f2e0dd..0763d3a61 100644 --- a/app/views/admin/configs/_miscellaneous.html.haml +++ b/app/views/admin/configs/_miscellaneous.html.haml @@ -11,6 +11,11 @@ authenticity_token: true do |f| =remote_form_input # This sends the partial_path to the controller, so it can serve back the correct partial + = f.input :application_title, required: true, + label: "Application Title", + input_html: {value: Config.application_title}, + as: :string + = f.input :dashboard_mode, require: true, label: "Dashboard Mode", include_blank: false, diff --git a/app/views/admin/configs/_trip_planning_apis.html.haml b/app/views/admin/configs/_trip_planning_apis.html.haml index 763ecba00..a94b770bc 100644 --- a/app/views/admin/configs/_trip_planning_apis.html.haml +++ b/app/views/admin/configs/_trip_planning_apis.html.haml @@ -15,20 +15,30 @@ label: "URL of the Open Trip Planner Server", input_html: {value: Config.open_trip_planner}, as: :string - - = f.input :otp_itinerary_quantity, required: true, - label: "The number of Itineraries we request from OTP per transit type. This may be different from the number of Itineraries that are shown", - input_html: {value: Config.otp_itinerary_quantity}, + + = f.input :otp_car_park_quantity, required: true, + label: "Amount of Car Park Itineraries requested from OTP. This may differ from the number of Itineraries shown", + input_html: {value: Config.otp_car_park_quantity}, + as: :integer + + = f.input :otp_transit_quantity, required: true, + label: "Amount of Transit Itineraries requested from OTP. This may differ from the number of Itineraries shown", + input_html: {value: Config.otp_transit_quantity}, as: :integer = f.input :otp_paratransit_quantity, required: true, - label: "The number of Itineraries we request from OTP specifically for paratransit trips. This may be different from the number of Itineraries that are shown", + label: "Amount of Paratransit Itineraries requested from OTP. This may differ from the number of Itineraries shown", input_html: {value: Config.otp_paratransit_quantity}, as: :integer + = f.input :otp_itinerary_quantity, required: true, + label: "Amount of Itineraries requested from OTP for all other types. This may differ from the number of Itineraries shown", + input_html: {value: Config.otp_itinerary_quantity}, + as: :integer + -# = f.input :otp_max_itineraries_shown, required: true, -# label: "The maximum number of requested Itineraries that we show per transit type.", - -# input_html: {value: Config.open_trip_planner}, + -# input_html: {value: Config.otp_max_itineraries_shown}, -# as: :integer =f.input :tff_api_key, required: false, diff --git a/app/views/user_mailer/_fmr_email_header.haml b/app/views/user_mailer/_fmr_email_header.haml index 0156824fe..7a66e198c 100644 --- a/app/views/user_mailer/_fmr_email_header.haml +++ b/app/views/user_mailer/_fmr_email_header.haml @@ -1,5 +1,5 @@ %h1{style: 'text-align:left'} - ="You have booked the following trip(s) via FindMyRidePA:" + =["You have booked the following trip(s)", Config.application_title.present? ? "via #{Config.application_title}" : nil].compact.join(" ") + ":" %p{style: 'text-align: left'} %span{style: 'font-weight: 700'} diff --git a/app/views/user_mailer/user_trip_email.html.haml b/app/views/user_mailer/user_trip_email.html.haml index b2a50cf74..a9a033a52 100644 --- a/app/views/user_mailer/user_trip_email.html.haml +++ b/app/views/user_mailer/user_trip_email.html.haml @@ -38,4 +38,6 @@ // Static Map %td{style: "text-align: center;", colspan: 2} %div{style: "width:100%;background: white; border-radius: 5px; padding: 10px;"} - =image_tag(attachments[@itinerary.id.to_s + ".png"].url) + - itin_map = attachments[@itinerary.id.to_s + ".png"] + - if itin_map + =image_tag(itin_map.url) diff --git a/app/views/user_mailer/user_trip_reminder.html.haml b/app/views/user_mailer/user_trip_reminder.html.haml index ce547a004..166899a57 100644 --- a/app/views/user_mailer/user_trip_reminder.html.haml +++ b/app/views/user_mailer/user_trip_reminder.html.haml @@ -6,7 +6,7 @@ %br %h1{style: 'text-align:left'} - ="Your saved Find My Ride trip for #{@itinerary.start_time.in_time_zone.strftime("%A, %B %-d")} is coming up in #{@days_away} days!" + =["Your saved", Config.application_title, "trip for #{@itinerary.start_time.in_time_zone.strftime("%A, %B %-d")} is coming up in #{@days_away} days!"].compact.join(" ") %h2{style: 'text-align:left'} ="Please see below for specific trip details:" %br diff --git a/config/initializers/version.rb b/config/initializers/version.rb index 59ebda5d1..0ae0ce9d9 100644 --- a/config/initializers/version.rb +++ b/config/initializers/version.rb @@ -1 +1 @@ -OneclickCore::Application.config.version='v1.18.7' +OneclickCore::Application.config.version='v1.18.8' diff --git a/spec/services/trip_planner_spec.rb b/spec/services/trip_planner_spec.rb index d47ff8347..97099f272 100644 --- a/spec/services/trip_planner_spec.rb +++ b/spec/services/trip_planner_spec.rb @@ -7,7 +7,7 @@ before(:each) { create(:tff_config) } before(:each) { create(:uber_token) } before(:each) { create(:lyft_client_token) } - let(:trip) {create :trip} + let(:trip) { create(:trip) } let(:accommodating_trip) { create(:trip, user: create(:user, :needs_accommodation)) } let!(:paratransit) { create(:paratransit_service, :medical_only, :ecolane_bookable) } let!(:taxi) { create(:taxi_service) } @@ -19,6 +19,11 @@ # TODO We need to make 2 contexts. One for travel patterns, and one for non travel patterns before do + otp_paratransit_1 = Service.find_by(gtfs_agency_id: "soundgenerations-wa-us:2291") + create(:paratransit_service, gtfs_agency_id: "soundgenerations-wa-us:2291") unless otp_paratransit_1 + + otp_paratransit_2 = Service.find_by(gtfs_agency_id: "kcm:1") + create(:paratransit_service, gtfs_agency_id: "kcm:1") unless otp_paratransit_2 # Config.create(key: "dashboard_mode", value: "travel_patterns") # allow(Service).to receive(:purposes) ... # allow(Config).to receive(:dashboard_mode) @@ -111,7 +116,7 @@ end itins = paratransit_tp.build_paratransit_itineraries expect(itins).to be_an(Array) - expect(itins.count).to eq(Paratransit.published.available_for(paratransit_tp.trip).count) + expect(itins.count).to eq(Paratransit.where(booking_api: nil).published.available_for(paratransit_tp.trip).count) expect(itins[0]).to be_an(Itinerary) end