diff options
| author | Luc Donnet | 2018-05-28 22:35:38 +0200 |
|---|---|---|
| committer | GitHub | 2018-05-28 22:35:38 +0200 |
| commit | 02f3c85cc054219a715bff86d119c6a0d10a7c36 (patch) | |
| tree | 10b44f152ddaf33e855d4184b84b94c21c55e13c | |
| parent | 3de76935e461c2b1302a086817d7d65ec6436b73 (diff) | |
| parent | a31065cc0ad7dc49bc3ea0475dbc9a87f8c612db (diff) | |
| download | chouette-core-02f3c85cc054219a715bff86d119c6a0d10a7c36.tar.bz2 | |
Merge pull request #569 from af83/6622-fix-loops-in-merge
6622 Ensure that the merge operation deals with loops well
| -rw-r--r-- | spec/models/merge_spec.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/models/merge_spec.rb b/spec/models/merge_spec.rb index 8c3f48272..f1df40b83 100644 --- a/spec/models/merge_spec.rb +++ b/spec/models/merge_spec.rb @@ -30,6 +30,13 @@ RSpec.describe Merge do stop_areas = stop_area_referential.stop_areas.order("random()").limit(5) FactoryGirl.create :route, line: line, stop_areas: stop_areas, stop_points_count: 0 end + # Loop + stop_areas = stop_area_referential.stop_areas.order("random()").limit(5) + route = FactoryGirl.create :route, line: line, stop_areas: stop_areas, stop_points_count: 0 + route.stop_points.create stop_area: stop_areas.first, position: route.stop_points.size + jp = route.full_journey_pattern + expect(route.stop_points.uniq.count).to eq route.stop_areas.uniq.count + 1 + expect(jp.stop_points.uniq.count).to eq jp.stop_areas.uniq.count + 1 end referential.routes.each_with_index do |route, index| @@ -65,7 +72,7 @@ RSpec.describe Merge do end referential.journey_patterns.each do |journey_pattern| - stop_points_positions[journey_pattern.name] = Hash[*journey_pattern.stop_points.map{|sp| [sp.stop_area_id, sp.position]}.flatten] + stop_points_positions[journey_pattern.name] = Hash[*journey_pattern.stop_points.map{|sp| [sp.position, sp.stop_area_id]}.flatten] factor.times do FactoryGirl.create :vehicle_journey, journey_pattern: journey_pattern, company: company end @@ -118,7 +125,7 @@ RSpec.describe Merge do # This should be enforced by the checksum preservation though output.journey_patterns.each do |journey_pattern| journey_pattern.stop_points.each do |sp| - expect(sp.position).to eq stop_points_positions[journey_pattern.name][sp.stop_area_id] + expect(sp.stop_area_id).to eq stop_points_positions[journey_pattern.name][sp.position] end end |
