ninoxe 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -12
- data/app/models/chouette/access_link.rb +52 -51
- data/app/models/chouette/access_point.rb +7 -7
- data/app/models/chouette/active_record.rb +28 -28
- data/app/models/chouette/company.rb +3 -3
- data/app/models/chouette/connection_link.rb +3 -3
- data/app/models/chouette/footnote.rb +1 -1
- data/app/models/chouette/group_of_line.rb +2 -2
- data/app/models/chouette/journey_pattern.rb +7 -3
- data/app/models/chouette/line.rb +11 -9
- data/app/models/chouette/network.rb +2 -2
- data/app/models/chouette/pt_link.rb +1 -1
- data/app/models/chouette/route.rb +9 -10
- data/app/models/chouette/stop_area.rb +8 -8
- data/app/models/chouette/stop_point.rb +3 -3
- data/app/models/chouette/time_table.rb +25 -122
- data/app/models/chouette/time_table_date.rb +1 -1
- data/app/models/chouette/time_table_period.rb +1 -1
- data/app/models/chouette/vehicle_journey.rb +82 -77
- data/app/models/chouette/vehicle_journey_at_stop.rb +1 -1
- data/config/database.yml +16 -8
- data/config/database.yml.travis +15 -6
- data/db/migrate/20150526075108_add_foreign_key_to_routes.rb +28 -0
- data/lib/ninoxe/engine.rb +4 -0
- data/lib/ninoxe/version.rb +1 -1
- data/lib/ninoxe.rb +3 -0
- data/spec/dummy/README.rdoc +15 -248
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/{mailers/.gitkeep → assets/images/.keep} +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +3 -5
- data/spec/dummy/app/assets/stylesheets/application.css +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/{models/.gitkeep → controllers/concerns/.keep} +0 -0
- data/spec/dummy/{lib/assets/.gitkeep → app/mailers/.keep} +0 -0
- data/spec/dummy/{log/.gitkeep → app/models/.keep} +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +8 -36
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/database.yml +16 -8
- data/spec/dummy/config/environment.rb +2 -4
- data/spec/dummy/config/environments/development.rb +11 -19
- data/spec/dummy/config/environments/production.rb +41 -28
- data/spec/dummy/config/environments/test.rb +13 -14
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -2
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/locales/fr.yml +23 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/schema.rb +147 -143
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +43 -11
- data/spec/dummy/public/422.html +43 -11
- data/spec/dummy/public/500.html +43 -11
- data/spec/dummy/script/rails +1 -1
- data/spec/factories/chouette_access_links.rb +13 -0
- data/spec/factories/chouette_access_points.rb +12 -0
- data/spec/factories/chouette_companies.rb +9 -0
- data/spec/factories/chouette_connection_links.rb +13 -0
- data/spec/factories/chouette_footnotes.rb +10 -0
- data/spec/factories/chouette_group_of_lines.rb +9 -0
- data/spec/factories/chouette_journey_pattern.rb +40 -0
- data/spec/factories/chouette_lines.rb +44 -0
- data/spec/factories/chouette_networks.rb +9 -0
- data/spec/factories/chouette_routes.rb +26 -0
- data/spec/factories/chouette_stop_areas.rb +12 -0
- data/spec/factories/chouette_stop_points.rb +10 -0
- data/spec/factories/chouette_time_table.rb +37 -0
- data/spec/factories/chouette_vehicle_journey.rb +66 -0
- data/spec/factories/chouette_vehicle_journey_at_stop.rb +8 -0
- data/spec/models/chouette/access_link_spec.rb +17 -13
- data/spec/models/chouette/access_point_spec.rb +106 -103
- data/spec/models/chouette/active_record_spec.rb +57 -57
- data/spec/models/chouette/area_type_spec.rb +8 -8
- data/spec/models/chouette/company_spec.rb +18 -18
- data/spec/models/chouette/connection_link_spec.rb +19 -15
- data/spec/models/chouette/direction_spec.rb +8 -8
- data/spec/models/chouette/exporter_spec.rb +4 -4
- data/spec/models/chouette/file_validator_spec.rb +4 -4
- data/spec/models/chouette/footnote_spec.rb +1 -1
- data/spec/models/chouette/group_of_line_spec.rb +11 -11
- data/spec/models/chouette/journey_pattern_spec.rb +16 -14
- data/spec/models/chouette/line_spec.rb +36 -32
- data/spec/models/chouette/loader_spec.rb +9 -9
- data/spec/models/chouette/network_spec.rb +9 -9
- data/spec/models/chouette/object_id_spec.rb +31 -28
- data/spec/models/chouette/route_spec.rb +51 -47
- data/spec/models/chouette/stop_area_spec.rb +191 -188
- data/spec/models/chouette/stop_point_spec.rb +13 -10
- data/spec/models/chouette/time_table_period_spec.rb +18 -18
- data/spec/models/chouette/time_table_spec.rb +303 -255
- data/spec/models/chouette/transport_mode_spec.rb +10 -10
- data/spec/models/chouette/trident_active_record_spec.rb +17 -17
- data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +13 -12
- data/spec/models/chouette/vehicle_journey_spec.rb +46 -46
- data/spec/presenters/chouette/geometry/line_presenter_spec.rb +2 -2
- data/spec/spec_helper.rb +22 -9
- metadata +102 -87
- data/config/database.yml.ci +0 -14
- data/lib/factories/chouette_access_links.rb +0 -11
- data/lib/factories/chouette_access_points.rb +0 -8
- data/lib/factories/chouette_companies.rb +0 -5
- data/lib/factories/chouette_connection_links.rb +0 -11
- data/lib/factories/chouette_footnotes.rb +0 -6
- data/lib/factories/chouette_group_of_lines.rb +0 -5
- data/lib/factories/chouette_journey_pattern.rb +0 -32
- data/lib/factories/chouette_lines.rb +0 -31
- data/lib/factories/chouette_networks.rb +0 -5
- data/lib/factories/chouette_routes.rb +0 -20
- data/lib/factories/chouette_stop_areas.rb +0 -8
- data/lib/factories/chouette_stop_points.rb +0 -7
- data/lib/factories/chouette_time_table.rb +0 -23
- data/lib/factories/chouette_vehicle_journey.rb +0 -51
- data/lib/factories/chouette_vehicle_journey_at_stop.rb +0 -5
- data/spec/dummy/config/initializers/active_record.rb +0 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::TransportMode do
|
3
|
+
describe Chouette::TransportMode, :type => :model do
|
4
4
|
|
5
5
|
def mode(text_code = "test", numerical_code = nil)
|
6
6
|
numerical_code ||= 1 if text_code == "test"
|
@@ -10,31 +10,31 @@ describe Chouette::TransportMode do
|
|
10
10
|
describe "#to_i" do
|
11
11
|
|
12
12
|
it "should return numerical code" do
|
13
|
-
mode("test", 1).to_i.
|
13
|
+
expect(mode("test", 1).to_i).to eq(1)
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return true to #test? when text code is 'test'" do
|
19
|
-
mode("test").
|
19
|
+
expect(mode("test")).to be_test
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should be equal when text codes are identical" do
|
23
|
-
mode("test",1).
|
23
|
+
expect(mode("test",1)).to eq(mode("test", 2))
|
24
24
|
end
|
25
25
|
|
26
26
|
describe ".new" do
|
27
27
|
|
28
28
|
it "should find numerical code from text code" do
|
29
|
-
mode("unknown").to_i.
|
29
|
+
expect(mode("unknown").to_i).to eq(0)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should find text code from numerical code" do
|
33
|
-
mode(0).
|
33
|
+
expect(mode(0)).to be_unknown
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should accept another mode" do
|
37
|
-
Chouette::TransportMode.new(mode("test")).
|
37
|
+
expect(Chouette::TransportMode.new(mode("test"))).to eq(mode("test"))
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -42,11 +42,11 @@ describe Chouette::TransportMode do
|
|
42
42
|
describe "#public_transport?" do
|
43
43
|
|
44
44
|
it "should return false for interchange" do
|
45
|
-
mode("interchange").
|
45
|
+
expect(mode("interchange")).not_to be_public_transport
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should return true for other modes" do
|
49
|
-
mode("unknown").
|
49
|
+
expect(mode("unknown")).to be_public_transport
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -55,7 +55,7 @@ describe Chouette::TransportMode do
|
|
55
55
|
|
56
56
|
Chouette::TransportMode.definitions.each do |text_code, numerical_code|
|
57
57
|
it "should include a TransportMode #{text_code}" do
|
58
|
-
Chouette::TransportMode.all.
|
58
|
+
expect(Chouette::TransportMode.all).to include(Chouette::TransportMode.new(text_code))
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -1,29 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::TridentActiveRecord do
|
3
|
+
describe Chouette::TridentActiveRecord, :type => :model do
|
4
4
|
|
5
|
-
it { Chouette::TridentActiveRecord.ancestors.
|
5
|
+
it { expect(Chouette::TridentActiveRecord.ancestors).to include(Chouette::ActiveRecord) }
|
6
6
|
|
7
|
-
subject {
|
7
|
+
subject { create(:time_table) }
|
8
8
|
|
9
9
|
describe "#uniq_objectid" do
|
10
10
|
|
11
11
|
it "should rebuild objectid" do
|
12
|
-
tm =
|
12
|
+
tm = create(:time_table)
|
13
13
|
tm.objectid = subject.objectid
|
14
14
|
tm.uniq_objectid
|
15
|
-
tm.objectid.
|
15
|
+
expect(tm.objectid).to eq(subject.objectid+"_1")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should rebuild objectid" do
|
19
|
-
tm =
|
19
|
+
tm = create(:time_table)
|
20
20
|
tm.objectid = subject.objectid
|
21
21
|
tm.uniq_objectid
|
22
22
|
tm.save
|
23
|
-
tm =
|
23
|
+
tm = create(:time_table)
|
24
24
|
tm.objectid = subject.objectid
|
25
25
|
tm.uniq_objectid
|
26
|
-
tm.objectid.
|
26
|
+
expect(tm.objectid).to eq(subject.objectid+"_2")
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -33,19 +33,19 @@ describe Chouette::TridentActiveRecord do
|
|
33
33
|
it "should left objectid" do
|
34
34
|
tm = Chouette::TimeTable.new :comment => "merge1" , :objectid => "NINOXE:Timetable:merge1"
|
35
35
|
tm.prepare_auto_columns
|
36
|
-
tm.objectid.
|
36
|
+
expect(tm.objectid).to eq("NINOXE:Timetable:merge1")
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should add pending_id to objectid" do
|
40
40
|
tm = Chouette::TimeTable.new :comment => "merge1"
|
41
41
|
tm.prepare_auto_columns
|
42
|
-
tm.objectid.start_with?("NINOXE:Timetable:__pending_id__").
|
42
|
+
expect(tm.objectid.start_with?("NINOXE:Timetable:__pending_id__")).to be_truthy
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should set id to objectid" do
|
46
46
|
tm = Chouette::TimeTable.new :comment => "merge1"
|
47
47
|
tm.save
|
48
|
-
tm.objectid.
|
48
|
+
expect(tm.objectid).to eq("NINOXE:Timetable:"+tm.id.to_s)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should detect objectid conflicts" do
|
@@ -55,7 +55,7 @@ describe Chouette::TridentActiveRecord do
|
|
55
55
|
tm.save
|
56
56
|
tm = Chouette::TimeTable.new :comment => "merge1"
|
57
57
|
tm.save
|
58
|
-
tm.objectid.
|
58
|
+
expect(tm.objectid).to eq("NINOXE:Timetable:"+tm.id.to_s+"_1")
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
@@ -65,14 +65,14 @@ describe Chouette::TridentActiveRecord do
|
|
65
65
|
it "should build automatic objectid when empty" do
|
66
66
|
g1 = Chouette::GroupOfLine.new( :name => "g1")
|
67
67
|
g1.save
|
68
|
-
g1.objectid.
|
68
|
+
expect(g1.objectid).to eq("NINOXE:GroupOfLine:"+g1.id.to_s)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should build automatic objectid with fixed when only suffix given" do
|
72
72
|
g1 = Chouette::GroupOfLine.new( :name => "g1")
|
73
73
|
g1.objectid = "toto"
|
74
74
|
g1.save
|
75
|
-
g1.objectid.
|
75
|
+
expect(g1.objectid).to eq("NINOXE:GroupOfLine:toto")
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should build automatic objectid with extension when already exists" do
|
@@ -83,7 +83,7 @@ describe Chouette::TridentActiveRecord do
|
|
83
83
|
g1.save
|
84
84
|
g2 = Chouette::GroupOfLine.new( :name => "g2")
|
85
85
|
g2.save
|
86
|
-
g2.objectid.
|
86
|
+
expect(g2.objectid).to eq("NINOXE:GroupOfLine:"+g2.id.to_s+"_1")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should build automatic objectid with extension when already exists" do
|
@@ -97,7 +97,7 @@ describe Chouette::TridentActiveRecord do
|
|
97
97
|
g2.save
|
98
98
|
g3 = Chouette::GroupOfLine.new( :name => "g3")
|
99
99
|
g3.save
|
100
|
-
g3.objectid.
|
100
|
+
expect(g3.objectid).to eq("NINOXE:GroupOfLine:"+g3.id.to_s+"_2")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should build automatic objectid when id cleared" do
|
@@ -106,7 +106,7 @@ describe Chouette::TridentActiveRecord do
|
|
106
106
|
g1.save
|
107
107
|
g1.objectid = nil
|
108
108
|
g1.save
|
109
|
-
g1.objectid.
|
109
|
+
expect(g1.objectid).to eq("NINOXE:GroupOfLine:"+g1.id.to_s)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -1,19 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'pp'
|
2
3
|
|
3
|
-
describe Chouette::VehicleJourneyAtStop do
|
4
|
-
let!(:vehicle_journey){
|
4
|
+
describe Chouette::VehicleJourneyAtStop, :type => :model do
|
5
|
+
let!(:vehicle_journey) { create(:vehicle_journey_odd)}
|
5
6
|
subject { vehicle_journey.vehicle_journey_at_stops.first }
|
6
7
|
|
7
8
|
describe "#exceeds_gap?" do
|
8
9
|
it "should return false if gap < 1.hour" do
|
9
10
|
t1 = 1.minutes.ago
|
10
11
|
t2 = 1.minutes.ago + 3.hour
|
11
|
-
subject.exceeds_gap?(t1, t2).
|
12
|
+
expect(subject.exceeds_gap?(t1, t2)).to be_truthy
|
12
13
|
end
|
13
14
|
it "should return false if gap > 2.hour" do
|
14
15
|
t1 = 1.minutes.ago
|
15
16
|
t2 = 1.minutes.ago + 3.minutes
|
16
|
-
subject.exceeds_gap?(t1, t2).
|
17
|
+
expect(subject.exceeds_gap?(t1, t2)).to be_falsey
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -23,23 +24,23 @@ describe Chouette::VehicleJourneyAtStop do
|
|
23
24
|
context "when vjas#arrival_time exceeds gap" do
|
24
25
|
it "should add errors on arrival_time" do
|
25
26
|
vjas1.arrival_time = vjas2.arrival_time - 3.hour
|
26
|
-
vjas2.increasing_times_validate(vjas1).
|
27
|
-
vjas2.errors.
|
28
|
-
vjas2.errors[:arrival_time].
|
27
|
+
expect(vjas2.increasing_times_validate(vjas1)).to be_falsey
|
28
|
+
expect(vjas2.errors).not_to be_empty
|
29
|
+
expect(vjas2.errors[:arrival_time]).not_to be_blank
|
29
30
|
end
|
30
31
|
end
|
31
32
|
context "when vjas#departure_time exceeds gap" do
|
32
33
|
it "should add errors on departure_time" do
|
33
34
|
vjas1.departure_time = vjas2.departure_time - 3.hour
|
34
|
-
vjas2.increasing_times_validate(vjas1).
|
35
|
-
vjas2.errors.
|
36
|
-
vjas2.errors[:departure_time].
|
35
|
+
expect(vjas2.increasing_times_validate(vjas1)).to be_falsey
|
36
|
+
expect(vjas2.errors).not_to be_empty
|
37
|
+
expect(vjas2.errors[:departure_time]).not_to be_blank
|
37
38
|
end
|
38
39
|
end
|
39
40
|
context "when vjas does'nt exceed gap" do
|
40
41
|
it "should not add errors" do
|
41
|
-
vjas2.increasing_times_validate(vjas1).
|
42
|
-
vjas2.errors.
|
42
|
+
expect(vjas2.increasing_times_validate(vjas1)).to be_truthy
|
43
|
+
expect(vjas2.errors).to be_empty
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
@@ -1,80 +1,80 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::VehicleJourney do
|
4
|
-
subject {
|
3
|
+
describe Chouette::VehicleJourney, :type => :model do
|
4
|
+
subject { create(:vehicle_journey_odd) }
|
5
5
|
|
6
6
|
describe "in_relation_to_a_journey_pattern methods" do
|
7
|
-
let!(:route) {
|
8
|
-
let!(:journey_pattern) {
|
9
|
-
let!(:journey_pattern_odd) {
|
10
|
-
let!(:journey_pattern_even) {
|
7
|
+
let!(:route) { create(:route)}
|
8
|
+
let!(:journey_pattern) { create(:journey_pattern, :route => route)}
|
9
|
+
let!(:journey_pattern_odd) { create(:journey_pattern_odd, :route => route)}
|
10
|
+
let!(:journey_pattern_even) { create(:journey_pattern_even, :route => route)}
|
11
11
|
|
12
12
|
context "when vehicle_journey is on odd stop whereas selected journey_pattern is on all stops" do
|
13
|
-
subject {
|
13
|
+
subject { create(:vehicle_journey, :route => route, :journey_pattern => journey_pattern_odd)}
|
14
14
|
describe "#extra_stops_in_relation_to_a_journey_pattern" do
|
15
15
|
it "should be empty" do
|
16
|
-
subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern).
|
16
|
+
expect(subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern)).to be_empty
|
17
17
|
end
|
18
18
|
end
|
19
19
|
describe "#extra_vjas_in_relation_to_a_journey_pattern" do
|
20
20
|
it "should be empty" do
|
21
|
-
subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern).
|
21
|
+
expect(subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern)).to be_empty
|
22
22
|
end
|
23
23
|
end
|
24
24
|
describe "#missing_stops_in_relation_to_a_journey_pattern" do
|
25
25
|
it "should return even stops" do
|
26
26
|
result = subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern)
|
27
|
-
result.
|
27
|
+
expect(result).to eq(journey_pattern_even.stop_points)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
describe "#update_journey_pattern" do
|
31
31
|
it "should new_record for added vjas" do
|
32
32
|
subject.update_journey_pattern( journey_pattern)
|
33
33
|
subject.vehicle_journey_at_stops.select{ |vjas| vjas.new_record? }.each do |vjas|
|
34
|
-
journey_pattern_even.stop_points.
|
34
|
+
expect(journey_pattern_even.stop_points).to include( vjas.stop_point)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
it "should add vjas on each even stops" do
|
38
38
|
subject.update_journey_pattern( journey_pattern)
|
39
39
|
vehicle_stops = subject.vehicle_journey_at_stops.map(&:stop_point)
|
40
40
|
journey_pattern_even.stop_points.each do |sp|
|
41
|
-
vehicle_stops.
|
41
|
+
expect(vehicle_stops).to include(sp)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
it "should not mark any vjas as _destroy" do
|
45
45
|
subject.update_journey_pattern( journey_pattern)
|
46
|
-
subject.vehicle_journey_at_stops.any?{ |vjas| vjas._destroy }.
|
46
|
+
expect(subject.vehicle_journey_at_stops.any?{ |vjas| vjas._destroy }).to be_falsey
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
context "when vehicle_journey is on all stops whereas selected journey_pattern is on odd stops" do
|
51
|
-
subject {
|
51
|
+
subject { create(:vehicle_journey, :route => route, :journey_pattern => journey_pattern)}
|
52
52
|
describe "#missing_stops_in_relation_to_a_journey_pattern" do
|
53
53
|
it "should be empty" do
|
54
|
-
subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern_odd).
|
54
|
+
expect(subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern_odd)).to be_empty
|
55
55
|
end
|
56
56
|
end
|
57
57
|
describe "#extra_stops_in_relation_to_a_journey_pattern" do
|
58
58
|
it "should return even stops" do
|
59
59
|
result = subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern_odd)
|
60
|
-
result.
|
60
|
+
expect(result).to eq(journey_pattern_even.stop_points)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
describe "#extra_vjas_in_relation_to_a_journey_pattern" do
|
64
64
|
it "should return vjas on even stops" do
|
65
65
|
result = subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern_odd)
|
66
|
-
result.map(&:stop_point).
|
66
|
+
expect(result.map(&:stop_point)).to eq(journey_pattern_even.stop_points)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
describe "#update_journey_pattern" do
|
70
70
|
it "should add no new vjas" do
|
71
71
|
subject.update_journey_pattern( journey_pattern_odd)
|
72
|
-
subject.vehicle_journey_at_stops.any?{ |vjas| vjas.new_record? }.
|
72
|
+
expect(subject.vehicle_journey_at_stops.any?{ |vjas| vjas.new_record? }).to be_falsey
|
73
73
|
end
|
74
74
|
it "should mark vehicle_journey_at_stops as _destroy on even stops" do
|
75
75
|
subject.update_journey_pattern( journey_pattern_odd)
|
76
76
|
subject.vehicle_journey_at_stops.each { |vjas|
|
77
|
-
vjas._destroy.
|
77
|
+
expect(vjas._destroy).to eq(journey_pattern_even.stop_points.include?(vjas.stop_point))
|
78
78
|
}
|
79
79
|
end
|
80
80
|
end
|
@@ -90,8 +90,8 @@ describe Chouette::VehicleJourney do
|
|
90
90
|
end
|
91
91
|
it "should make instance invalid" do
|
92
92
|
subject.increasing_times
|
93
|
-
subject.vehicle_journey_at_stops[1].errors[:departure_time].
|
94
|
-
subject.
|
93
|
+
expect(subject.vehicle_journey_at_stops[1].errors[:departure_time]).not_to be_blank
|
94
|
+
expect(subject).not_to be_valid
|
95
95
|
end
|
96
96
|
end
|
97
97
|
describe "#update_attributes" do
|
@@ -100,48 +100,48 @@ describe Chouette::VehicleJourney do
|
|
100
100
|
"1"=>{"id" => subject.vehicle_journey_at_stops[1].id, "arrival_time" => (1.minutes.ago + 2.hour),"departure_time" => (1.minutes.ago + 2.hour)}
|
101
101
|
}}}
|
102
102
|
it "should return false" do
|
103
|
-
subject.update_attributes(params).
|
103
|
+
expect(subject.update_attributes(params)).to be_falsey
|
104
104
|
end
|
105
105
|
it "should make instance invalid" do
|
106
106
|
subject.update_attributes(params)
|
107
|
-
subject.
|
107
|
+
expect(subject).not_to be_valid
|
108
108
|
end
|
109
109
|
it "should let first vjas without any errors" do
|
110
110
|
subject.update_attributes(params)
|
111
|
-
subject.vehicle_journey_at_stops[0].errors.
|
111
|
+
expect(subject.vehicle_journey_at_stops[0].errors).to be_empty
|
112
112
|
end
|
113
113
|
it "should add an error on second vjas" do
|
114
114
|
subject.update_attributes(params)
|
115
|
-
subject.vehicle_journey_at_stops[1].errors[:departure_time].
|
115
|
+
expect(subject.vehicle_journey_at_stops[1].errors[:departure_time]).not_to be_blank
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context "#time_table_tokens=" do
|
121
|
-
let!(:tm1){
|
122
|
-
let!(:tm2){
|
121
|
+
let!(:tm1){create(:time_table, :comment => "TM1")}
|
122
|
+
let!(:tm2){create(:time_table, :comment => "TM2")}
|
123
123
|
|
124
124
|
it "should return associated time table ids" do
|
125
125
|
subject.update_attributes :time_table_tokens => [tm1.id, tm2.id].join(',')
|
126
|
-
subject.time_tables.
|
127
|
-
subject.time_tables.
|
126
|
+
expect(subject.time_tables).to include( tm1)
|
127
|
+
expect(subject.time_tables).to include( tm2)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
describe "#bounding_dates" do
|
131
131
|
before(:each) do
|
132
|
-
tm1 =
|
133
|
-
|
134
|
-
|
135
|
-
tm2 =
|
136
|
-
|
137
|
-
tm3 =
|
132
|
+
tm1 = build(:time_table, :dates =>
|
133
|
+
[ build(:time_table_date, :date => 1.days.ago.to_date, :in_out => true),
|
134
|
+
build(:time_table_date, :date => 2.days.ago.to_date, :in_out => true) ])
|
135
|
+
tm2 = build(:time_table, :periods =>
|
136
|
+
[ build(:time_table_period, :period_start => 4.days.ago.to_date, :period_end => 3.days.ago.to_date)])
|
137
|
+
tm3 = build(:time_table)
|
138
138
|
subject.time_tables = [ tm1, tm2, tm3]
|
139
139
|
end
|
140
140
|
it "should return min date from associated calendars" do
|
141
|
-
subject.bounding_dates.min.
|
141
|
+
expect(subject.bounding_dates.min).to eq(4.days.ago.to_date)
|
142
142
|
end
|
143
143
|
it "should return max date from associated calendars" do
|
144
|
-
subject.bounding_dates.max.
|
144
|
+
expect(subject.bounding_dates.max).to eq(1.days.ago.to_date)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
context "#vehicle_journey_at_stops" do
|
@@ -150,7 +150,7 @@ describe Chouette::VehicleJourney do
|
|
150
150
|
vj_stop_ids = subject.vehicle_journey_at_stops.map(&:stop_point_id)
|
151
151
|
expected_order = route.stop_points.map(&:id).select {|s_id| vj_stop_ids.include?(s_id)}
|
152
152
|
|
153
|
-
vj_stop_ids.
|
153
|
+
expect(vj_stop_ids).to eq(expected_order)
|
154
154
|
end
|
155
155
|
|
156
156
|
end
|
@@ -166,14 +166,14 @@ describe Chouette::VehicleJourney do
|
|
166
166
|
transport_mode_name = Chouette::TransportMode.new(transport_mode.underscore)
|
167
167
|
it "should be #{transport_mode_name}" do
|
168
168
|
subject.transport_mode = transport_mode
|
169
|
-
subject.transport_mode_name.
|
169
|
+
expect(subject.transport_mode_name).to eq(transport_mode_name)
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
173
|
context "when transport_mode is nil" do
|
174
174
|
it "should be nil" do
|
175
175
|
subject.transport_mode = nil
|
176
|
-
subject.transport_mode_name.
|
176
|
+
expect(subject.transport_mode_name).to be_nil
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -183,7 +183,7 @@ describe Chouette::VehicleJourney do
|
|
183
183
|
|
184
184
|
it "should change transport_mode with TransportMode#name" do
|
185
185
|
subject.transport_mode_name = "Test"
|
186
|
-
subject.transport_mode.
|
186
|
+
expect(subject.transport_mode).to eq("Test")
|
187
187
|
end
|
188
188
|
|
189
189
|
end
|
@@ -191,21 +191,21 @@ describe Chouette::VehicleJourney do
|
|
191
191
|
describe ".transport_mode_names" do
|
192
192
|
|
193
193
|
it "should not include unknown transport_mode_name" do
|
194
|
-
Chouette::VehicleJourney.transport_mode_names.
|
194
|
+
expect(Chouette::VehicleJourney.transport_mode_names).not_to include(Chouette::TransportMode.new("unknown"))
|
195
195
|
end
|
196
196
|
|
197
197
|
it "should not include interchange transport_mode" do
|
198
|
-
Chouette::VehicleJourney.transport_mode_names.
|
198
|
+
expect(Chouette::VehicleJourney.transport_mode_names).not_to include(Chouette::TransportMode.new("interchange"))
|
199
199
|
end
|
200
200
|
|
201
201
|
end
|
202
202
|
|
203
203
|
describe "#footnote_ids=" do
|
204
204
|
context "when line have footnotes, " do
|
205
|
-
let!( :route) {
|
205
|
+
let!( :route) { create( :route ) }
|
206
206
|
let!( :line) { route.line }
|
207
|
-
let!( :footnote_first) {
|
208
|
-
let!( :footnote_second) {
|
207
|
+
let!( :footnote_first) {create( :footnote, :code => "1", :label => "dummy 1", :line => route.line)}
|
208
|
+
let!( :footnote_second) {create( :footnote, :code => "2", :label => "dummy 2", :line => route.line)}
|
209
209
|
|
210
210
|
|
211
211
|
it "should update vehicle's footnotes" do
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Chouette::Geometry::LinePresenter do
|
4
|
-
let!(:line) {
|
4
|
+
let!(:line) { create(:line_with_stop_areas_having_parent) }
|
5
5
|
subject { Chouette::Geometry::LinePresenter.new(line)}
|
6
6
|
|
7
7
|
describe "#routes_localized_commercials" do
|
8
8
|
it "should return 3 stop_areas" do
|
9
|
-
subject.routes_localized_commercials(line.routes.first).size.
|
9
|
+
expect(subject.routes_localized_commercials(line.routes.first).size).to eq(10)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
# Configure Rails Envinronment
|
2
|
-
ENV["RAILS_ENV"]
|
2
|
+
ENV["RAILS_ENV"] ||= "test"
|
3
|
+
require 'spec_helper'
|
3
4
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
-
|
5
5
|
require 'rspec/rails'
|
6
|
-
require 'rspec/autorun'
|
7
6
|
|
7
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
8
8
|
require 'shoulda-matchers'
|
9
9
|
require 'factory_girl_rails'
|
10
|
-
|
11
10
|
require 'geo_ruby'
|
12
11
|
|
12
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
13
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
14
|
+
# run as spec files by default. This means that files in spec/support that end
|
15
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
16
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
17
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
18
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
19
|
+
#
|
20
|
+
# The following line is provided for convenience purposes. It has the downside
|
21
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
22
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
23
|
+
# require only the support files necessary.
|
24
|
+
#
|
13
25
|
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
14
26
|
|
15
27
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
@@ -17,7 +29,13 @@ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
|
17
29
|
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
18
30
|
Dir[File.join(ENGINE_RAILS_ROOT, "lib/factories/**/*.rb")].each {|f| require f }
|
19
31
|
|
32
|
+
# Checks for pending migrations before tests are run.
|
33
|
+
# If you are not using ActiveRecord, you can remove this line.
|
34
|
+
ActiveRecord::Migration.maintain_test_schema!
|
35
|
+
|
20
36
|
RSpec.configure do |config|
|
37
|
+
config.include FactoryGirl::Syntax::Methods
|
38
|
+
|
21
39
|
# == Mock Framework
|
22
40
|
#
|
23
41
|
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
@@ -35,11 +53,6 @@ RSpec.configure do |config|
|
|
35
53
|
# instead of true.
|
36
54
|
config.use_transactional_fixtures = true
|
37
55
|
|
38
|
-
# If true, the base class of anonymous controllers will be inferred
|
39
|
-
# automatically. This will be the default behavior in future versions of
|
40
|
-
# rspec-rails.
|
41
|
-
config.infer_base_class_for_anonymous_controllers = false
|
42
|
-
|
43
56
|
end
|
44
57
|
|
45
58
|
|