diff options
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! |
