diff options
| author | Xinhui | 2016-11-10 16:09:19 +0100 | 
|---|---|---|
| committer | Xinhui | 2016-11-10 17:02:00 +0100 | 
| commit | f0a63658e609eef1f1e3967ac0729e5543974203 (patch) | |
| tree | 559a9ff220bc885e82fe91f767cd78187d547dd2 /spec/models/clean_up_spec.rb | |
| parent | 7adac45929c93e298bb4e0198d8c8bafdfcc91e2 (diff) | |
| download | chouette-core-f0a63658e609eef1f1e3967ac0729e5543974203.tar.bz2 | |
Wip refactoring CleanUp clean method
Refs #1933
Diffstat (limited to 'spec/models/clean_up_spec.rb')
| -rw-r--r-- | spec/models/clean_up_spec.rb | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/spec/models/clean_up_spec.rb b/spec/models/clean_up_spec.rb new file mode 100644 index 000000000..d633443ba --- /dev/null +++ b/spec/models/clean_up_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe CleanUp, :type => :model do +  let(:cleaner) { CleanUp.new } + +  it 'should delete physical stop_areas without stop_points' do +    create_list(:stop_area, 2) +    create_list(:stop_point, 2) +    Chouette::StopArea.update_all(area_type: "Quay") +    expect(cleaner.physical_stop_areas.count).to eq 2 +    expect(cleaner.clean_physical_stop_areas).to eq 2 +  end + +  it 'should delete vehiclejourneys without timetables' do +    create_list(:vehicle_journey, 2) +    create_list(:vehicle_journey, 2, time_tables:[create(:time_table)]) +    expect(cleaner.vehicle_journeys.count).to eq 2 +    expect(cleaner.clean_vehicle_journeys).to eq 2 +  end + +  it 'should delete lines without routes' do +    create_list(:line, 2) +    create_list(:route, 2, line: create(:line)) +    expect(cleaner.lines.count).to eq 2 +    expect(cleaner.clean_lines).to eq 2 +  end + +  it 'should delete routes without journeypatterns' do +    create_list(:route, 2) +    create_list(:journey_pattern, 2, route: create(:route)) +    expect(cleaner.routes.count).to eq 2 +    expect(cleaner.clean_routes).to eq 2 +  end + +  it 'should delete journeypatterns without vehicle journeys' do +    create_list(:journey_pattern, 2) +    create_list(:vehicle_journey, 2, journey_pattern: create(:journey_pattern)) +    expect(cleaner.journey_patterns.count).to eq 2 +    expect(cleaner.clean_journey_patterns).to eq 2 +  end +end | 
