diff options
| author | Alban Peignier | 2017-12-17 22:14:17 +0100 | 
|---|---|---|
| committer | Alban Peignier | 2018-01-05 10:23:29 +0100 | 
| commit | 78c2b9deaefa4aa5c0ac5173055cb2cacd3d27c1 (patch) | |
| tree | 7c61327521783f9a921e595319f2d4862b0342cf /spec/models/merge_spec.rb | |
| parent | f90488de1f657abf24026231485c87d3e42ee11d (diff) | |
| download | chouette-core-78c2b9deaefa4aa5c0ac5173055cb2cacd3d27c1.tar.bz2 | |
First try for route/stop_point and journey_pattern merge. RefsĀ #5299
Diffstat (limited to 'spec/models/merge_spec.rb')
| -rw-r--r-- | spec/models/merge_spec.rb | 32 | 
1 files changed, 30 insertions, 2 deletions
| diff --git a/spec/models/merge_spec.rb b/spec/models/merge_spec.rb index caa623357..92ffc8267 100644 --- a/spec/models/merge_spec.rb +++ b/spec/models/merge_spec.rb @@ -3,8 +3,36 @@ require "rails_helper"  RSpec.describe Merge do    it "should work" do -    referential_metadata = FactoryGirl.create(:referential_metadata) -    referential = FactoryGirl.create :workbench_referential, metadatas: [referential_metadata] +    stop_area_referential = FactoryGirl.create :stop_area_referential +    10.times { FactoryGirl.create :stop_area, stop_area_referential: stop_area_referential } + +    line_referential = FactoryGirl.create :line_referential +    company = FactoryGirl.create :company, line_referential: line_referential +    10.times { FactoryGirl.create :line, line_referential: line_referential, company: company, network: nil } + +    workbench = FactoryGirl.create :workbench, line_referential: line_referential, stop_area_referential: stop_area_referential + +    referential_metadata = FactoryGirl.create(:referential_metadata, lines: line_referential.lines.limit(3)) + +    referential = FactoryGirl.create :referential, +                                      workbench: workbench, +                                      organisation: workbench.organisation, +                                      metadatas: [referential_metadata] + +    referential.switch do +      line_referential.lines.each do |line| +        3.times do +          stop_areas = stop_area_referential.stop_areas.order("random()").limit(5) +          FactoryGirl.create :route, line: line, stop_areas: stop_areas +        end +      end + +      referential.routes.each do |route| +        3.times do +          FactoryGirl.create :journey_pattern, route: route, stop_points: route.stop_points.sample(3) +        end +      end +    end      merge = Merge.create!(workbench: referential.workbench, referentials: [referential, referential])      merge.merge! | 
