diff --git a/app/models/journey.rb b/app/models/journey.rb index a6f6532ba..e72b41fa4 100644 --- a/app/models/journey.rb +++ b/app/models/journey.rb @@ -81,6 +81,7 @@ def for_feed .merge(to_location.for_feed(prefix: :to)) .merge(supplier.for_feed) .merge(vehicle_registration:) + .merge(vehicle_depot:) end def vehicle_registration diff --git a/spec/factories/journeys.rb b/spec/factories/journeys.rb index 89d8b6dce..27ab114ed 100644 --- a/spec/factories/journeys.rb +++ b/spec/factories/journeys.rb @@ -5,7 +5,7 @@ association(:from_location, factory: :location) association(:to_location, :court, factory: :location) client_timestamp { Time.zone.now.utc + rand(-60..60).seconds } # NB: the client_timestamp will never be perfectly in sync with system clock - vehicle { { id: '12345678ABC', registration: 'AB12 CDE' } } + vehicle { { id: '12345678ABC', registration: 'AB12 CDE', depot: 'Depot 1' } } date { Time.zone.today } # NB we need to initialize_state because FactoryBot fires the after_initialize callback before the attributes are initialised! diff --git a/spec/models/journey_spec.rb b/spec/models/journey_spec.rb index e9f25cb40..93852580b 100644 --- a/spec/models/journey_spec.rb +++ b/spec/models/journey_spec.rb @@ -160,6 +160,7 @@ 'date': be_a(Date), 'state': 'proposed', 'vehicle_registration': 'AB12 CDE', + 'vehicle_depot': 'Depot 1', 'client_timestamp': be_a(Time), 'created_at': be_a(Time), 'updated_at': be_a(Time), diff --git a/spec/requests/api/journeys_controller_update_spec.rb b/spec/requests/api/journeys_controller_update_spec.rb index c0ad40ea3..1123a9db1 100644 --- a/spec/requests/api/journeys_controller_update_spec.rb +++ b/spec/requests/api/journeys_controller_update_spec.rb @@ -163,7 +163,7 @@ it 'does not update the underlying journey vehicle' do do_patch - expect(journey.vehicle).to eql('id' => '12345678ABC', 'registration' => 'AB12 CDE') + expect(journey.vehicle).to eql('id' => '12345678ABC', 'registration' => 'AB12 CDE', 'depot' => 'Depot 1') end end @@ -218,7 +218,7 @@ it 'does not update the underlying journey vehicle' do do_patch - expect(journey.vehicle).to eql('id' => '12345678ABC', 'registration' => 'AB12 CDE') + expect(journey.vehicle).to eql('id' => '12345678ABC', 'registration' => 'AB12 CDE', 'depot' => 'Depot 1') end end diff --git a/spec/serializers/journey_serializer_spec.rb b/spec/serializers/journey_serializer_spec.rb index 445250956..e267c296a 100644 --- a/spec/serializers/journey_serializer_spec.rb +++ b/spec/serializers/journey_serializer_spec.rb @@ -34,7 +34,7 @@ end it 'contains vehicle attributes' do - expect(result[:data][:attributes][:vehicle]).to eql(id: '12345678ABC', registration: 'AB12 CDE') + expect(result[:data][:attributes][:vehicle]).to eql(id: '12345678ABC', registration: 'AB12 CDE', depot: 'Depot 1') end it 'contains a `from_location` relationship' do diff --git a/spec/serializers/journeys_serializer_spec.rb b/spec/serializers/journeys_serializer_spec.rb index b80baf0a3..545bfc868 100644 --- a/spec/serializers/journeys_serializer_spec.rb +++ b/spec/serializers/journeys_serializer_spec.rb @@ -34,7 +34,7 @@ end it 'contains vehicle attributes' do - expect(result[:data][:attributes][:vehicle]).to eql(id: '12345678ABC', registration: 'AB12 CDE') + expect(result[:data][:attributes][:vehicle]).to eql(id: '12345678ABC', registration: 'AB12 CDE', depot: 'Depot 1') end it 'contains a `from_location` relationship' do