aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteddywing2018-02-12 11:42:37 +0100
committerGitHub2018-02-12 11:42:37 +0100
commit59be983ba9e2343d9361ccf31ead62b297c8a623 (patch)
treed76836b065dd0674e9a72870c097d15cb2b985ae
parent7f044f8ab9cf9394c4180f3d467a74bd95dcd398 (diff)
parenta22431f51860699546486c407cfc398a9ae5a911 (diff)
downloadchouette-core-59be983ba9e2343d9361ccf31ead62b297c8a623.tar.bz2
Merge pull request #298 from af83/5432-fix-vjas-json-serialization
5432 Fix vj#show.rabl
-rw-r--r--app/views/vehicle_journeys/show.rabl4
-rw-r--r--spec/controllers/vehicle_journeys_controller_spec.rb24
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