diff options
| author | Vlatka Pavisic | 2017-04-18 18:17:17 +0200 |
|---|---|---|
| committer | Vlatka Pavisic | 2017-04-18 18:17:23 +0200 |
| commit | 33e796dc89b36f7c57adb9d462c0cc35a15be623 (patch) | |
| tree | 1a9d3df51ed18aba8cdf08cee8276287a5bdf5db /spec | |
| parent | 07f17622daadc36db95fcf087798842f783e0f09 (diff) | |
| download | chouette-core-33e796dc89b36f7c57adb9d462c0cc35a15be623.tar.bz2 | |
Refs #3132 #3135 #3136 ITL StopArea validations
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/chouette/routing_constraint_zone_spec.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/spec/models/chouette/routing_constraint_zone_spec.rb b/spec/models/chouette/routing_constraint_zone_spec.rb index c83942456..0f34db5f9 100644 --- a/spec/models/chouette/routing_constraint_zone_spec.rb +++ b/spec/models/chouette/routing_constraint_zone_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Chouette::RoutingConstraintZone, type: :model do subject { create(:routing_constraint_zone) } + let!(:routing_constraint_zone) { create(:routing_constraint_zone) } it { is_expected.to validate_presence_of :name } # shoulda matcher to validate length of array ? @@ -10,31 +11,34 @@ describe Chouette::RoutingConstraintZone, type: :model do describe 'validations' do it 'validates the presence of route_id' do - routing_constraint_zone = create(:routing_constraint_zone) expect { routing_constraint_zone.update!(route_id: nil) }.to raise_error end it 'validates the presence of stop_point_ids' do - routing_constraint_zone = create(:routing_constraint_zone) expect { routing_constraint_zone.update!(stop_point_ids: []) }.to raise_error(ActiveRecord::RecordInvalid) end it 'validates that stop points belong to the route' do - routing_constraint_zone = create(:routing_constraint_zone) route = create(:route) expect { routing_constraint_zone.update!(route_id: route.id) }.to raise_error(ActiveRecord::RecordInvalid) end + + it 'validates that not all stop points from the route are selected' do + routing_constraint_zone.stop_points = routing_constraint_zone.route.stop_points + expect { + routing_constraint_zone.save! + }.to raise_error(ActiveRecord::RecordInvalid) + end end describe 'deleted stop areas' do it 'does not have them in stop_area_ids' do - routing_constraint_zone = create(:routing_constraint_zone) stop_point = routing_constraint_zone.route.stop_points.last routing_constraint_zone.stop_points << stop_point routing_constraint_zone.save! |
