aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlban Peignier2017-12-28 15:42:11 +0100
committerAlban Peignier2017-12-28 15:42:11 +0100
commitb9bcf2fc557c7e17451f4101ae4157cf7671cc6b (patch)
treed342cd46228e7b3cbbfa842a88e579036761a3f5 /spec
parent31965824161284176fee1fddfce7e2fe3894ad7e (diff)
downloadchouette-core-b9bcf2fc557c7e17451f4101ae4157cf7671cc6b.tar.bz2
Add specs on StopArea parent area_type validation. Refuse parent of the same type. Refs #53135313_stop_areas_parent
Diffstat (limited to 'spec')
-rw-r--r--spec/models/chouette/stop_area_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/chouette/stop_area_spec.rb b/spec/models/chouette/stop_area_spec.rb
index bec8c0868..9db0f11a5 100644
--- a/spec/models/chouette/stop_area_spec.rb
+++ b/spec/models/chouette/stop_area_spec.rb
@@ -426,6 +426,42 @@ describe Chouette::StopArea, :type => :model do
# end
# end
+ describe "#parent" do
+
+ let(:stop_area) { FactoryGirl.build :stop_area, parent: FactoryGirl.build(:stop_area) }
+
+ it "is valid when parent has an 'higher' type" do
+ stop_area.area_type = 'zdep'
+ stop_area.parent.area_type = 'zdlp'
+
+ stop_area.valid?
+ expect(stop_area.errors).to_not have_key(:parent_id)
+ end
+
+ it "is valid when parent is undefined" do
+ stop_area.parent = nil
+
+ stop_area.valid?
+ expect(stop_area.errors).to_not have_key(:parent_id)
+ end
+
+ it "isn't valid when parent has the same type" do
+ stop_area.parent.area_type = stop_area.area_type = 'zdep'
+
+ stop_area.valid?
+ expect(stop_area.errors).to have_key(:parent_id)
+ end
+
+ it "isn't valid when parent has a lower type" do
+ stop_area.area_type = 'lda'
+ stop_area.parent.area_type = 'zdep'
+
+ stop_area.valid?
+ expect(stop_area.errors).to have_key(:parent_id)
+ end
+
+ end
+
describe '#waiting_time' do
let(:stop_area) { FactoryGirl.build :stop_area }