diff options
| -rw-r--r-- | app/views/vehicle_journeys/show.rabl | 4 | ||||
| -rw-r--r-- | spec/controllers/vehicle_journeys_controller_spec.rb | 24 | 
2 files changed, 25 insertions, 3 deletions
| diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl index dca0866b3..546c851a4 100644 --- a/app/views/vehicle_journeys/show.rabl +++ b/app/views/vehicle_journeys/show.rabl @@ -39,10 +39,8 @@ child :footnotes, :object_root => false do |footnotes|  end  child(:vehicle_journey_at_stops_matrix, :object_root => false) do |vehicle_stops| +  attributes :id, :connecting_service_id, :boarding_alighting_possibility    node do |vehicle_stop| -    [:id, :connecting_service_id, :boarding_alighting_possibility].map do |att| -      node(att) { vehicle_stop.send(att) ? vehicle_stop.send(att) : nil  } -    end      node(:dummy) { vehicle_stop.dummy }      node(:area_kind) { vehicle_stop.stop_point.stop_area.kind } diff --git a/spec/controllers/vehicle_journeys_controller_spec.rb b/spec/controllers/vehicle_journeys_controller_spec.rb index 416450c21..300684532 100644 --- a/spec/controllers/vehicle_journeys_controller_spec.rb +++ b/spec/controllers/vehicle_journeys_controller_spec.rb @@ -26,4 +26,28 @@ RSpec.describe VehicleJourneysController, :type => :controller do      end    end +  describe "GET index" do +    login_user +    render_views + +    context "in JSON" do +      let(:vehicle_journey){ create :vehicle_journey } +      let(:route){ vehicle_journey.route } +      let(:line){ route.line } +      let!(:request){ get :index, referential_id: referential.id, line_id: line.id, route_id: route.id, format: :json} +      let(:parsed_response){ JSON.parse response.body } +      it "should have all the attributes" do +        expect(response).to have_http_status 200 +        vehicle_journey = parsed_response["vehicle_journeys"].first +        vehicle_journey_at_stops_matrix = vehicle_journey["vehicle_journey_at_stops"] +        vehicle_journey_at_stops_matrix.each do |received_vjas| +          expect(received_vjas).to have_key("id") +          vjas = Chouette::VehicleJourneyAtStop.find received_vjas["id"] +          [:connecting_service_id, :boarding_alighting_possibility].each do |att| +            expect(received_vjas[att]).to eq vjas.send(att) +          end +        end +      end +    end +  end  end | 
