diff options
| author | Zog | 2018-04-25 18:40:25 +0200 |
|---|---|---|
| committer | Zog | 2018-04-25 18:40:25 +0200 |
| commit | 6c61ffc242a562aeac83317c756e09d8ad210815 (patch) | |
| tree | 4beac3f794b3b42f60517647fb157c706dce2b4b /spec | |
| parent | 53990515457b7618e9b2b36832751ad8622fd56e (diff) | |
| download | chouette-core-6c61ffc242a562aeac83317c756e09d8ad210815.tar.bz2 | |
Refs #6762; Fix bug on RoutingConstraintsZone merge
And add some specs
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/merge_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/models/merge_spec.rb b/spec/models/merge_spec.rb index 95181a80e..685e675cd 100644 --- a/spec/models/merge_spec.rb +++ b/spec/models/merge_spec.rb @@ -22,6 +22,8 @@ RSpec.describe Merge do factor = 1 stop_points_positions = {} + routing_constraint_zones = {} + referential.switch do line_referential.lines.each do |line| factor.times do @@ -35,6 +37,16 @@ RSpec.describe Merge do sp.set_list_position 0 end route.reload.update_checksum! + checksum = route.checksum + routing_constraint_zones[route.id] = {} + 2.times do |i| + constraint_zone = create(:routing_constraint_zone, route: route) + if i > 0 + constraint_zone.update stop_points: constraint_zone.stop_points[0...-1] + end + routing_constraint_zones[route.id][constraint_zone.checksum] = constraint_zone + end + expect(route.reload.checksum).to_not eq checksum factor.times do FactoryGirl.create :journey_pattern, route: route, stop_points: route.stop_points.sample(3) end @@ -54,7 +66,9 @@ RSpec.describe Merge do specific_time_table = FactoryGirl.create :time_table vehicle_journey.time_tables << specific_time_table + vehicle_journey.update ignored_routing_contraint_zone_ids: routing_constraint_zones[vehicle_journey.route.id].values.map(&:id) end + end merge = Merge.create!(workbench: referential.workbench, referentials: [referential, referential]) @@ -63,6 +77,27 @@ RSpec.describe Merge do output = merge.output.current output.switch + output.routes.each do |route| + stop_points = nil + old_route = nil + referential.switch do + old_route = Chouette::Route.find_by(checksum: route.checksum) + stop_points = {} + old_route.routing_constraint_zones.each do |constraint_zone| + stop_points[constraint_zone.checksum] = constraint_zone.stop_points.map(&:registration_number) + end + end + routing_constraint_zones[old_route.id].each do |checksum, constraint_zone| + new_constraint_zone = route.routing_constraint_zones.where(checksum: checksum).last + expect(new_constraint_zone).to be_present + expect(new_constraint_zone.stop_points.map(&:registration_number)).to eq stop_points[checksum] + end + + route.vehicle_journeys.each do |vehicle_journey| + expect(vehicle_journey.ignored_routing_contraint_zones.size).to eq vehicle_journey.ignored_routing_contraint_zone_ids.size + end + end + # Let's check stop_point positions are respected # This should be enforced by the checksum preservation though output.journey_patterns.each do |journey_pattern| |
