aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuc Donnet2018-01-31 12:20:25 +0100
committerGitHub2018-01-31 12:20:25 +0100
commit4fa30ef61bd334de0627267b7b2eda4e09c8b728 (patch)
treefa73d3d20cfa67a818b6f1d5f3a0a03898659cad /spec
parente54ee3a4379afb763906ab2ba2fd980349c48334 (diff)
parentc463c3a950246c4c2660ce7df1c1ea8f2acbe578 (diff)
downloadchouette-core-4fa30ef61bd334de0627267b7b2eda4e09c8b728.tar.bz2
Merge pull request #263 from af83/5750-non-commercial-stop-areas
5750 non commercial stop areas
Diffstat (limited to 'spec')
-rw-r--r--spec/javascript/vehicle_journeys/actions_spec.js41
-rw-r--r--spec/models/chouette/area_type_spec.rb4
-rw-r--r--spec/models/chouette/stop_area_spec.rb10
3 files changed, 54 insertions, 1 deletions
diff --git a/spec/javascript/vehicle_journeys/actions_spec.js b/spec/javascript/vehicle_journeys/actions_spec.js
index 9515b57f2..d486c9af8 100644
--- a/spec/javascript/vehicle_journeys/actions_spec.js
+++ b/spec/javascript/vehicle_journeys/actions_spec.js
@@ -37,6 +37,47 @@ describe('when clicking on add button', () => {
expect(actions.openCreateModal()).toEqual(expectedAction)
})
})
+describe('when validating the form', () => {
+ it('should check that non-commercial stops have passing time', () => {
+ let state = [{
+ vehicle_journey_at_stops: [{
+ area_kind: "non_commercial",
+ departure_time: {
+ hour: "00",
+ minute: "00"
+ }
+ }]
+ }]
+
+ expect(actions.validate(dispatch, state)).toEqual(false)
+
+ state = [{
+ vehicle_journey_at_stops: [{
+ area_kind: "non_commercial",
+ departure_time: {
+ hour: "00",
+ minute: "01"
+ }
+ }]
+ }]
+
+ expect(actions.validate(dispatch, state)).toEqual(true)
+ })
+
+ it('should not check that commercial stops', () => {
+ let state = [{
+ vehicle_journey_at_stops: [{
+ area_kind: "commercial",
+ departure_time: {
+ hour: "00",
+ minute: "00"
+ }
+ }]
+ }]
+
+ expect(actions.validate(dispatch, state)).toEqual(true)
+ })
+})
describe('when using select2 to pick a journey pattern', () => {
it('should create an action to select a journey pattern inside modal', () => {
let selectedJP = {
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
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"