From 22c38fb750843f0c74996175a6bd17a1f20a943c Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 26 Jan 2018 16:17:22 +0100 Subject: Refs #5750 @1h; Add a "kind" attribute to StopAreas This determines if the StopArea is commercial or not The useless fields are hidden in the form for the non-commercials ones --- spec/models/chouette/area_type_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec/models') diff --git a/spec/models/chouette/area_type_spec.rb b/spec/models/chouette/area_type_spec.rb index 67d218df8..28325dd0a 100644 --- a/spec/models/chouette/area_type_spec.rb +++ b/spec/models/chouette/area_type_spec.rb @@ -4,7 +4,9 @@ RSpec.describe Chouette::AreaType do describe "::ALL" do it "includes all supported types" do - expect(Chouette::AreaType::ALL).to match_array( %i(zdep zder zdlp zdlr lda gdl) ) + expect(Chouette::AreaType::ALL).to match_array( %i(zdep zder zdlp zdlr lda gdl deposit border service_area relief other) ) + expect(Chouette::AreaType::COMMERCIAL).to match_array( %i(zdep zder zdlp zdlr lda gdl) ) + expect(Chouette::AreaType::NON_COMMERCIAL).to match_array( %i( deposit border service_area relief other) ) end end -- cgit v1.2.3 From 05bc96db48a0a84fd2c50e457dc767f88950a9b4 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 29 Jan 2018 08:45:02 +0100 Subject: Refs #5750 @1h; Manage non-commercial StopAreas - Add a `kind` attribute - Hide irrelevant fields in the form --- spec/models/chouette/stop_area_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/models') diff --git a/spec/models/chouette/stop_area_spec.rb b/spec/models/chouette/stop_area_spec.rb index a90e5d816..32ee5a3a6 100644 --- a/spec/models/chouette/stop_area_spec.rb +++ b/spec/models/chouette/stop_area_spec.rb @@ -10,10 +10,20 @@ describe Chouette::StopArea, :type => :model do it { should belong_to(:stop_area_referential) } it { should validate_presence_of :name } + it { should validate_presence_of :kind } it { should validate_numericality_of :latitude } it { should validate_numericality_of :longitude } it { is_expected.to be_versioned } + describe "#area_type" do + it "should validate the value is correct regarding to the kind" do + expect(build(:stop_area, kind: :commercial, area_type: :gdl)).to be_valid + expect(build(:stop_area, kind: :non_commercial, area_type: :relief)).to be_valid + expect(build(:stop_area, kind: :commercial, area_type: :relief)).to_not be_valid + expect(build(:stop_area, kind: :non_commercial, area_type: :gdl)).to_not be_valid + end + end + # describe ".latitude" do # it "should accept -90 value" do # subject = create :stop_area, :area_type => "BoardingPosition" -- cgit v1.2.3