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,166 +1,169 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::StopArea do
|
4
|
-
let!(:quay) {
|
5
|
-
let!(:boarding_position) {
|
6
|
-
let!(:commercial_stop_point) {
|
7
|
-
let!(:stop_place) {
|
8
|
-
let!(:itl) {
|
9
|
-
|
10
|
-
|
3
|
+
describe Chouette::StopArea, :type => :model do
|
4
|
+
let!(:quay) { create :stop_area, :area_type => "Quay" }
|
5
|
+
let!(:boarding_position) { create :stop_area, :area_type => "BoardingPosition" }
|
6
|
+
let!(:commercial_stop_point) { create :stop_area, :area_type => "CommercialStopPoint" }
|
7
|
+
let!(:stop_place) { create :stop_area, :area_type => "StopPlace" }
|
8
|
+
let!(:itl) { create :stop_area, :area_type => "ITL" }
|
9
|
+
|
10
|
+
describe '#objectid' do
|
11
|
+
subject { super().objectid }
|
12
|
+
it { is_expected.to be_kind_of(Chouette::ObjectId) }
|
13
|
+
end
|
11
14
|
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
15
|
+
it { is_expected.to validate_presence_of :name }
|
16
|
+
it { is_expected.to validate_presence_of :area_type }
|
17
|
+
it { is_expected.to validate_numericality_of :latitude }
|
18
|
+
it { is_expected.to validate_numericality_of :longitude }
|
16
19
|
|
17
20
|
|
18
21
|
describe ".latitude" do
|
19
22
|
it "should accept -90 value" do
|
20
|
-
subject =
|
23
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
21
24
|
subject.latitude = -90
|
22
|
-
subject.valid
|
25
|
+
expect(subject.valid?).to be_truthy
|
23
26
|
end
|
24
27
|
it "should reject < -90 value" do
|
25
|
-
subject =
|
28
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
26
29
|
subject.latitude = -90.0001
|
27
|
-
subject.valid
|
30
|
+
expect(subject.valid?).to be_falsey
|
28
31
|
end
|
29
32
|
it "should accept 90 value" do
|
30
|
-
subject =
|
33
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
31
34
|
subject.latitude = 90
|
32
|
-
subject.valid
|
35
|
+
expect(subject.valid?).to be_truthy
|
33
36
|
end
|
34
37
|
it "should reject > 90 value" do
|
35
|
-
subject =
|
38
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
36
39
|
subject.latitude = 90.0001
|
37
|
-
subject.valid
|
40
|
+
expect(subject.valid?).to be_falsey
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
describe ".longitude" do
|
42
45
|
it "should accept -180 value" do
|
43
|
-
subject =
|
46
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
44
47
|
subject.longitude = -180
|
45
|
-
subject.valid
|
48
|
+
expect(subject.valid?).to be_truthy
|
46
49
|
end
|
47
50
|
it "should reject < -180 value" do
|
48
|
-
subject =
|
51
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
49
52
|
subject.longitude = -180.0001
|
50
|
-
subject.valid
|
53
|
+
expect(subject.valid?).to be_falsey
|
51
54
|
end
|
52
55
|
it "should accept 180 value" do
|
53
|
-
subject =
|
56
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
54
57
|
subject.longitude = 180
|
55
|
-
subject.valid
|
58
|
+
expect(subject.valid?).to be_truthy
|
56
59
|
end
|
57
60
|
it "should reject > 180 value" do
|
58
|
-
subject =
|
61
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
59
62
|
subject.longitude = 180.0001
|
60
|
-
subject.valid
|
63
|
+
expect(subject.valid?).to be_falsey
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
67
|
describe ".long_lat" do
|
65
68
|
it "should accept longitude and latitude both as nil" do
|
66
|
-
subject =
|
69
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
67
70
|
subject.longitude = nil
|
68
71
|
subject.latitude = nil
|
69
|
-
subject.valid
|
72
|
+
expect(subject.valid?).to be_truthy
|
70
73
|
end
|
71
74
|
it "should accept longitude and latitude both numerical" do
|
72
|
-
subject =
|
75
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
73
76
|
subject.longitude = 10
|
74
77
|
subject.latitude = 10
|
75
|
-
subject.valid
|
78
|
+
expect(subject.valid?).to be_truthy
|
76
79
|
end
|
77
80
|
it "should reject longitude nil with latitude numerical" do
|
78
|
-
subject =
|
81
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
79
82
|
subject.longitude = nil
|
80
83
|
subject.latitude = 10
|
81
|
-
subject.valid
|
84
|
+
expect(subject.valid?).to be_falsey
|
82
85
|
end
|
83
86
|
it "should reject longitude numerical with latitude nil" do
|
84
|
-
subject =
|
87
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
85
88
|
subject.longitude = 10
|
86
89
|
subject.latitude = nil
|
87
|
-
subject.valid
|
90
|
+
expect(subject.valid?).to be_falsey
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
91
94
|
|
92
95
|
describe ".children_in_depth" do
|
93
96
|
it "should return all the deepest children from stop area" do
|
94
|
-
subject =
|
95
|
-
commercial_stop_point =
|
96
|
-
commercial_stop_point2 =
|
97
|
-
quay =
|
98
|
-
subject.children_in_depth.
|
97
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
98
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint", :parent => subject
|
99
|
+
commercial_stop_point2 = create :stop_area, :area_type => "CommercialStopPoint", :parent => commercial_stop_point
|
100
|
+
quay = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
101
|
+
expect(subject.children_in_depth).to match_array([commercial_stop_point, commercial_stop_point2, quay])
|
99
102
|
end
|
100
103
|
it "should return only the deepest children from stop area" do
|
101
|
-
subject =
|
102
|
-
commercial_stop_point =
|
103
|
-
commercial_stop_point2 =
|
104
|
-
quay =
|
105
|
-
subject.children_at_base.
|
104
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
105
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint", :parent => subject
|
106
|
+
commercial_stop_point2 = create :stop_area, :area_type => "CommercialStopPoint", :parent => commercial_stop_point
|
107
|
+
quay = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
108
|
+
expect(subject.children_at_base).to match_array([quay])
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
109
112
|
describe ".stop_area_type" do
|
110
113
|
it "should have area_type of BoardingPosition when stop_area_type is set to boarding_position" do
|
111
|
-
subject =
|
112
|
-
subject.area_type.
|
114
|
+
subject = create :stop_area, :stop_area_type => "boarding_position"
|
115
|
+
expect(subject.area_type).to eq("BoardingPosition")
|
113
116
|
end
|
114
117
|
it "should have area_type of Quay when stop_area_type is set to quay" do
|
115
|
-
subject =
|
116
|
-
subject.area_type.
|
118
|
+
subject = create :stop_area, :stop_area_type => "quay"
|
119
|
+
expect(subject.area_type).to eq("Quay")
|
117
120
|
end
|
118
121
|
it "should have area_type of CommercialStopPoint when stop_area_type is set to commercial_stop_point" do
|
119
|
-
subject =
|
120
|
-
subject.area_type.
|
122
|
+
subject = create :stop_area, :stop_area_type => "commercial_stop_point"
|
123
|
+
expect(subject.area_type).to eq("CommercialStopPoint")
|
121
124
|
end
|
122
125
|
it "should have area_type of StopPlace when stop_area_type is set to stop_place" do
|
123
|
-
subject =
|
124
|
-
subject.area_type.
|
126
|
+
subject = create :stop_area, :stop_area_type => "stop_place"
|
127
|
+
expect(subject.area_type).to eq("StopPlace")
|
125
128
|
end
|
126
129
|
it "should have area_type of ITL when stop_area_type is set to itl" do
|
127
|
-
subject =
|
128
|
-
subject.area_type.
|
130
|
+
subject = create :stop_area, :stop_area_type => "itl"
|
131
|
+
expect(subject.area_type).to eq("ITL")
|
129
132
|
end
|
130
133
|
end
|
131
134
|
|
132
135
|
describe ".parent" do
|
133
136
|
it "should check if parent method exists" do
|
134
|
-
subject =
|
135
|
-
subject.parent.
|
137
|
+
subject = create :stop_area, :parent_id => commercial_stop_point.id
|
138
|
+
expect(subject.parent).to eq(commercial_stop_point)
|
136
139
|
end
|
137
140
|
end
|
138
141
|
|
139
142
|
describe ".possible_children" do
|
140
143
|
|
141
144
|
it "should find no possible descendant for stop area type quay" do
|
142
|
-
subject =
|
143
|
-
subject.possible_children.
|
145
|
+
subject = create :stop_area, :area_type => "Quay"
|
146
|
+
expect(subject.possible_children).to eq([])
|
144
147
|
end
|
145
148
|
|
146
149
|
it "should find no possible descendant for stop area type boarding position" do
|
147
|
-
subject =
|
148
|
-
subject.possible_children.
|
150
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
151
|
+
expect(subject.possible_children).to eq([])
|
149
152
|
end
|
150
153
|
|
151
154
|
it "should find descendant of type quay or boarding position for stop area type commercial stop point" do
|
152
|
-
subject =
|
153
|
-
subject.possible_children.
|
155
|
+
subject = create :stop_area, :area_type => "CommercialStopPoint"
|
156
|
+
expect(subject.possible_children).to match_array([quay, boarding_position])
|
154
157
|
end
|
155
158
|
|
156
159
|
it "should find no children of type stop place or commercial stop point for stop area type stop place" do
|
157
|
-
subject =
|
158
|
-
subject.possible_children.
|
160
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
161
|
+
expect(subject.possible_children).to match_array([stop_place, commercial_stop_point])
|
159
162
|
end
|
160
163
|
|
161
164
|
it "should find no children of type ITL for stop area type ITL" do
|
162
|
-
subject =
|
163
|
-
subject.possible_children.
|
165
|
+
subject = create :stop_area, :area_type => "ITL"
|
166
|
+
expect(subject.possible_children).to match_array([stop_place, commercial_stop_point, quay, boarding_position])
|
164
167
|
end
|
165
168
|
|
166
169
|
end
|
@@ -168,23 +171,23 @@ describe Chouette::StopArea do
|
|
168
171
|
describe ".possible_parents" do
|
169
172
|
|
170
173
|
it "should find parent type commercial stop point for stop area type boarding position" do
|
171
|
-
subject =
|
172
|
-
subject.possible_parents.
|
174
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
175
|
+
expect(subject.possible_parents).to eq([commercial_stop_point])
|
173
176
|
end
|
174
177
|
|
175
178
|
it "should find parent type commercial stop point for stop area type quay" do
|
176
|
-
subject =
|
177
|
-
subject.possible_parents.
|
179
|
+
subject = create :stop_area, :area_type => "Quay"
|
180
|
+
expect(subject.possible_parents).to eq([commercial_stop_point])
|
178
181
|
end
|
179
182
|
|
180
183
|
it "should find parent type stop place for stop area type commercial stop point" do
|
181
|
-
subject =
|
182
|
-
subject.possible_parents.
|
184
|
+
subject = create :stop_area, :area_type => "CommercialStopPoint"
|
185
|
+
expect(subject.possible_parents).to eq([stop_place])
|
183
186
|
end
|
184
187
|
|
185
188
|
it "should find parent type stop place for stop area type stop place" do
|
186
|
-
subject =
|
187
|
-
subject.possible_parents.
|
189
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
190
|
+
expect(subject.possible_parents).to eq([stop_place])
|
188
191
|
end
|
189
192
|
|
190
193
|
end
|
@@ -192,15 +195,15 @@ describe Chouette::StopArea do
|
|
192
195
|
|
193
196
|
describe ".near" do
|
194
197
|
|
195
|
-
let(:stop_area) {
|
196
|
-
let(:stop_area2) {
|
198
|
+
let(:stop_area) { create :stop_area, :latitude => 1, :longitude => 1 }
|
199
|
+
let(:stop_area2) { create :stop_area, :latitude => 1, :longitude => 1 }
|
197
200
|
|
198
201
|
it "should find a StopArea at 300m from given origin" do
|
199
|
-
Chouette::StopArea.near(stop_area.to_lat_lng.endpoint(0, 0.250, :units => :kms)).
|
202
|
+
expect(Chouette::StopArea.near(stop_area.to_lat_lng.endpoint(0, 0.250, :units => :kms))).to eq([stop_area])
|
200
203
|
end
|
201
204
|
|
202
205
|
it "should not find a StopArea at more than 300m from given origin" do
|
203
|
-
Chouette::StopArea.near(stop_area2.to_lat_lng.endpoint(0, 0.350, :units => :kms)).
|
206
|
+
expect(Chouette::StopArea.near(stop_area2.to_lat_lng.endpoint(0, 0.350, :units => :kms))).to be_empty
|
204
207
|
end
|
205
208
|
|
206
209
|
end
|
@@ -209,12 +212,12 @@ describe Chouette::StopArea do
|
|
209
212
|
|
210
213
|
it "should return nil if latitude is nil" do
|
211
214
|
subject.latitude = nil
|
212
|
-
subject.to_lat_lng.
|
215
|
+
expect(subject.to_lat_lng).to be_nil
|
213
216
|
end
|
214
217
|
|
215
218
|
it "should return nil if longitude is nil" do
|
216
219
|
subject.longitude = nil
|
217
|
-
subject.to_lat_lng.
|
220
|
+
expect(subject.to_lat_lng).to be_nil
|
218
221
|
end
|
219
222
|
|
220
223
|
end
|
@@ -222,8 +225,8 @@ describe Chouette::StopArea do
|
|
222
225
|
describe "#geometry" do
|
223
226
|
|
224
227
|
it "should be nil when to_lat_lng is nil" do
|
225
|
-
subject.
|
226
|
-
subject.geometry.
|
228
|
+
allow(subject).to receive_messages :to_lat_lng => nil
|
229
|
+
expect(subject.geometry).to be_nil
|
227
230
|
end
|
228
231
|
|
229
232
|
end
|
@@ -231,8 +234,8 @@ describe Chouette::StopArea do
|
|
231
234
|
describe ".bounds" do
|
232
235
|
|
233
236
|
it "should return transform coordinates in floats" do
|
234
|
-
Chouette::StopArea.connection.
|
235
|
-
GeoRuby::SimpleFeatures::Envelope.
|
237
|
+
allow(Chouette::StopArea.connection).to receive_messages :select_rows => [["113.5292500000000000", "22.1127580000000000", "113.5819330000000000", "22.2157050000000000"]]
|
238
|
+
expect(GeoRuby::SimpleFeatures::Envelope).to receive(:from_coordinates).with([[113.5292500000000000, 22.1127580000000000], [113.5819330000000000, 22.2157050000000000]])
|
236
239
|
Chouette::StopArea.bounds
|
237
240
|
end
|
238
241
|
|
@@ -241,70 +244,70 @@ describe Chouette::StopArea do
|
|
241
244
|
describe "#default_position" do
|
242
245
|
|
243
246
|
it "should return nil when StopArea.bounds is nil" do
|
244
|
-
Chouette::StopArea.
|
245
|
-
subject.default_position.
|
247
|
+
allow(Chouette::StopArea).to receive_messages :bounds => nil
|
248
|
+
expect(subject.default_position).to be_nil
|
246
249
|
end
|
247
250
|
|
248
251
|
it "should return StopArea.bounds center" do
|
249
|
-
Chouette::StopArea.
|
250
|
-
subject.default_position.
|
252
|
+
allow(Chouette::StopArea).to receive_messages :bounds => double(:center => "center")
|
253
|
+
expect(subject.default_position).to eq(Chouette::StopArea.bounds.center)
|
251
254
|
end
|
252
255
|
|
253
256
|
end
|
254
257
|
|
255
258
|
describe "#children_at_base" do
|
256
259
|
it "should have 2 children_at_base" do
|
257
|
-
subject =
|
258
|
-
commercial_stop_point =
|
259
|
-
quay1 =
|
260
|
-
quay2 =
|
261
|
-
subject.children_at_base.size.
|
260
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
261
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
|
262
|
+
quay1 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
263
|
+
quay2 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
264
|
+
expect(subject.children_at_base.size).to eq(2)
|
262
265
|
end
|
263
266
|
end
|
264
267
|
|
265
268
|
|
266
269
|
describe "#generic_access_link_matrix" do
|
267
270
|
it "should have no access_links in matrix with no access_point" do
|
268
|
-
subject =
|
269
|
-
commercial_stop_point =
|
270
|
-
subject.generic_access_link_matrix.size.
|
271
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
272
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
|
273
|
+
expect(subject.generic_access_link_matrix.size).to eq(0)
|
271
274
|
end
|
272
275
|
it "should have 4 generic_access_links in matrix with 2 access_points" do
|
273
|
-
subject =
|
274
|
-
commercial_stop_point =
|
275
|
-
access_point1 =
|
276
|
-
access_point2 =
|
277
|
-
subject.generic_access_link_matrix.size.
|
276
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
277
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
|
278
|
+
access_point1 = create :access_point, :stop_area => subject
|
279
|
+
access_point2 = create :access_point, :stop_area => subject
|
280
|
+
expect(subject.generic_access_link_matrix.size).to eq(4)
|
278
281
|
end
|
279
282
|
end
|
280
283
|
describe "#detail_access_link_matrix" do
|
281
284
|
it "should have no access_links in matrix with no access_point" do
|
282
|
-
subject =
|
283
|
-
commercial_stop_point =
|
284
|
-
quay1 =
|
285
|
-
quay2 =
|
286
|
-
subject.detail_access_link_matrix.size.
|
285
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
286
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
|
287
|
+
quay1 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
288
|
+
quay2 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
289
|
+
expect(subject.detail_access_link_matrix.size).to eq(0)
|
287
290
|
end
|
288
291
|
it "should have 8 detail_access_links in matrix with 2 children_at_base and 2 access_points" do
|
289
|
-
subject =
|
290
|
-
commercial_stop_point =
|
291
|
-
quay1 =
|
292
|
-
quay2 =
|
293
|
-
access_point1 =
|
294
|
-
access_point2 =
|
295
|
-
subject.detail_access_link_matrix.size.
|
292
|
+
subject = create :stop_area, :area_type => "StopPlace"
|
293
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
|
294
|
+
quay1 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
295
|
+
quay2 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
296
|
+
access_point1 = create :access_point, :stop_area => subject
|
297
|
+
access_point2 = create :access_point, :stop_area => subject
|
298
|
+
expect(subject.detail_access_link_matrix.size).to eq(8)
|
296
299
|
end
|
297
300
|
end
|
298
301
|
describe "#parents" do
|
299
302
|
it "should return parent hireachy list" do
|
300
|
-
stop_place =
|
301
|
-
commercial_stop_point =
|
302
|
-
subject =
|
303
|
-
subject.parents.size.
|
303
|
+
stop_place = create :stop_area, :area_type => "StopPlace"
|
304
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
|
305
|
+
subject = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
306
|
+
expect(subject.parents.size).to eq(2)
|
304
307
|
end
|
305
308
|
it "should return empty parent hireachy list" do
|
306
|
-
subject =
|
307
|
-
subject.parents.size.
|
309
|
+
subject = create :stop_area, :area_type => "Quay"
|
310
|
+
expect(subject.parents.size).to eq(0)
|
308
311
|
end
|
309
312
|
end
|
310
313
|
|
@@ -313,126 +316,126 @@ describe Chouette::StopArea do
|
|
313
316
|
# subject is a CSP with a SP as parent, a quay as child
|
314
317
|
# 2 access_points of SP have access_link, one on subject, one on subject child
|
315
318
|
# when detaching subject from SP, both access_links must be deleted
|
316
|
-
stop_place =
|
317
|
-
subject =
|
318
|
-
access_point1 =
|
319
|
-
access_point2 =
|
320
|
-
quay =
|
321
|
-
access_link1 =
|
322
|
-
access_link2 =
|
319
|
+
stop_place = create :stop_area, :area_type => "StopPlace"
|
320
|
+
subject = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
|
321
|
+
access_point1 = create :access_point, :stop_area => stop_place
|
322
|
+
access_point2 = create :access_point, :stop_area => stop_place
|
323
|
+
quay = create :stop_area, :parent => subject, :area_type => "Quay"
|
324
|
+
access_link1 = create :access_link, :stop_area => subject, :access_point => access_point1
|
325
|
+
access_link2 = create :access_link, :stop_area => quay, :access_point => access_point2
|
323
326
|
subject.save
|
324
|
-
subject.access_links.size.
|
325
|
-
quay.access_links.size.
|
327
|
+
expect(subject.access_links.size).to eq(1)
|
328
|
+
expect(quay.access_links.size).to eq(1)
|
326
329
|
subject.parent=nil
|
327
330
|
subject.save
|
328
331
|
subject.reload
|
329
|
-
subject.access_links.size.
|
330
|
-
quay.access_links.size.
|
332
|
+
expect(subject.access_links.size).to eq(0)
|
333
|
+
expect(quay.access_links.size).to eq(0)
|
331
334
|
end
|
332
335
|
it "should not remove still valid access links" do
|
333
336
|
# subject is a Q of CSP with a SP as parent
|
334
337
|
# 2 access_points, one of SP, one of CSP have access_link on subject
|
335
338
|
# when changing subject CSP to another CSP of same SP
|
336
339
|
# one access_links must be kept
|
337
|
-
stop_place =
|
338
|
-
commercial_stop_point1 =
|
339
|
-
commercial_stop_point2 =
|
340
|
-
access_point1 =
|
341
|
-
access_point2 =
|
342
|
-
subject =
|
343
|
-
access_link1 =
|
344
|
-
access_link2 =
|
340
|
+
stop_place = create :stop_area, :area_type => "StopPlace"
|
341
|
+
commercial_stop_point1 = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
|
342
|
+
commercial_stop_point2 = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
|
343
|
+
access_point1 = create :access_point, :stop_area => stop_place
|
344
|
+
access_point2 = create :access_point, :stop_area => commercial_stop_point1
|
345
|
+
subject = create :stop_area, :parent => commercial_stop_point1, :area_type => "Quay"
|
346
|
+
access_link1 = create :access_link, :stop_area => subject, :access_point => access_point1
|
347
|
+
access_link2 = create :access_link, :stop_area => subject, :access_point => access_point2
|
345
348
|
subject.save
|
346
|
-
subject.access_links.size.
|
349
|
+
expect(subject.access_links.size).to eq(2)
|
347
350
|
subject.parent=commercial_stop_point2
|
348
351
|
subject.save
|
349
352
|
subject.reload
|
350
|
-
subject.access_links.size.
|
353
|
+
expect(subject.access_links.size).to eq(1)
|
351
354
|
end
|
352
355
|
end
|
353
356
|
|
354
357
|
describe "#coordinates" do
|
355
358
|
it "should convert coordinates into latitude/longitude" do
|
356
|
-
subject =
|
357
|
-
subject.longitude.
|
358
|
-
subject.latitude.
|
359
|
+
subject = create :stop_area, :area_type => "BoardingPosition", :coordinates => "45.123,120.456"
|
360
|
+
expect(subject.longitude).to be_within(0.001).of(120.456)
|
361
|
+
expect(subject.latitude).to be_within(0.001).of(45.123)
|
359
362
|
end
|
360
363
|
it "should set empty coordinates into nil latitude/longitude" do
|
361
|
-
subject =
|
362
|
-
subject.longitude.
|
363
|
-
subject.latitude.
|
364
|
+
subject = create :stop_area, :area_type => "BoardingPosition", :coordinates => "45.123,120.456"
|
365
|
+
expect(subject.longitude).to be_within(0.001).of(120.456)
|
366
|
+
expect(subject.latitude).to be_within(0.001).of(45.123)
|
364
367
|
subject.coordinates = ""
|
365
368
|
subject.save
|
366
|
-
subject.longitude.
|
367
|
-
subject.latitude.
|
369
|
+
expect(subject.longitude).to be_nil
|
370
|
+
expect(subject.latitude).to be_nil
|
368
371
|
end
|
369
372
|
it "should convert latitude/longitude into coordinates" do
|
370
|
-
subject =
|
371
|
-
subject.coordinates.
|
373
|
+
subject = create :stop_area, :area_type => "BoardingPosition", :longitude => 120.456, :latitude => 45.123
|
374
|
+
expect(subject.coordinates).to eq("45.123,120.456")
|
372
375
|
end
|
373
376
|
it "should convert nil latitude/longitude into empty coordinates" do
|
374
|
-
subject =
|
375
|
-
subject.coordinates.
|
377
|
+
subject = create :stop_area, :area_type => "BoardingPosition", :longitude => nil, :latitude => nil
|
378
|
+
expect(subject.coordinates).to eq("")
|
376
379
|
end
|
377
380
|
it "should accept valid coordinates" do
|
378
|
-
subject =
|
379
|
-
subject.valid
|
381
|
+
subject = create :stop_area, :area_type => "BoardingPosition", :coordinates => "45.123,120.456"
|
382
|
+
expect(subject.valid?).to be_truthy
|
380
383
|
subject.coordinates = "45.123, 120.456"
|
381
|
-
subject.valid
|
382
|
-
subject.longitude.
|
383
|
-
subject.latitude.
|
384
|
+
expect(subject.valid?).to be_truthy
|
385
|
+
expect(subject.longitude).to be_within(0.001).of(120.456)
|
386
|
+
expect(subject.latitude).to be_within(0.001).of(45.123)
|
384
387
|
subject.coordinates = "45.123, -120.456"
|
385
|
-
subject.valid
|
388
|
+
expect(subject.valid?).to be_truthy
|
386
389
|
subject.coordinates = "45.123 ,120.456"
|
387
|
-
subject.valid
|
390
|
+
expect(subject.valid?).to be_truthy
|
388
391
|
subject.coordinates = "45.123 , 120.456"
|
389
|
-
subject.valid
|
392
|
+
expect(subject.valid?).to be_truthy
|
390
393
|
subject.coordinates = " 45.123,120.456"
|
391
|
-
subject.valid
|
394
|
+
expect(subject.valid?).to be_truthy
|
392
395
|
subject.coordinates = "45.123,120.456 "
|
393
|
-
subject.valid
|
396
|
+
expect(subject.valid?).to be_truthy
|
394
397
|
end
|
395
398
|
it "should accept valid coordinates on limits" do
|
396
|
-
subject =
|
397
|
-
subject.valid
|
399
|
+
subject = create :stop_area, :area_type => "BoardingPosition", :coordinates => "90,180"
|
400
|
+
expect(subject.valid?).to be_truthy
|
398
401
|
subject.coordinates = "-90,-180"
|
399
|
-
subject.valid
|
402
|
+
expect(subject.valid?).to be_truthy
|
400
403
|
subject.coordinates = "-90.,180."
|
401
|
-
subject.valid
|
404
|
+
expect(subject.valid?).to be_truthy
|
402
405
|
subject.coordinates = "-90.0,180.00"
|
403
|
-
subject.valid
|
406
|
+
expect(subject.valid?).to be_truthy
|
404
407
|
end
|
405
408
|
it "should reject invalid coordinates" do
|
406
|
-
subject =
|
409
|
+
subject = create :stop_area, :area_type => "BoardingPosition"
|
407
410
|
subject.coordinates = ",12"
|
408
|
-
subject.valid
|
411
|
+
expect(subject.valid?).to be_falsey
|
409
412
|
subject.coordinates = "-90"
|
410
|
-
subject.valid
|
413
|
+
expect(subject.valid?).to be_falsey
|
411
414
|
subject.coordinates = "-90.1,180."
|
412
|
-
subject.valid
|
415
|
+
expect(subject.valid?).to be_falsey
|
413
416
|
subject.coordinates = "-90.0,180.1"
|
414
|
-
subject.valid
|
417
|
+
expect(subject.valid?).to be_falsey
|
415
418
|
subject.coordinates = "-91.0,18.1"
|
416
|
-
subject.valid
|
419
|
+
expect(subject.valid?).to be_falsey
|
417
420
|
end
|
418
421
|
end
|
419
422
|
|
420
423
|
describe "#duplicate" do
|
421
424
|
it "should be a copy of" do
|
422
|
-
stop_place =
|
423
|
-
subject =
|
424
|
-
access_point1 =
|
425
|
-
access_point2 =
|
426
|
-
quay1 =
|
425
|
+
stop_place = create :stop_area, :area_type => "StopPlace"
|
426
|
+
subject = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place, :coordinates => "45.123,120.456"
|
427
|
+
access_point1 = create :access_point, :stop_area => subject
|
428
|
+
access_point2 = create :access_point, :stop_area => subject
|
429
|
+
quay1 = create :stop_area, :parent => subject, :area_type => "Quay"
|
427
430
|
target=subject.duplicate
|
428
|
-
target.id.
|
429
|
-
target.name.
|
430
|
-
target.objectid.
|
431
|
-
target.area_type.
|
432
|
-
target.parent.
|
433
|
-
target.children.size.
|
434
|
-
target.access_points.size.
|
435
|
-
target.coordinates.
|
431
|
+
expect(target.id).to be_nil
|
432
|
+
expect(target.name).to eq("Copy of "+subject.name)
|
433
|
+
expect(target.objectid).to eq(subject.objectid+"_1")
|
434
|
+
expect(target.area_type).to eq(subject.area_type)
|
435
|
+
expect(target.parent).to be_nil
|
436
|
+
expect(target.children.size).to eq(0)
|
437
|
+
expect(target.access_points.size).to eq(0)
|
438
|
+
expect(target.coordinates).to eq("45.123,120.456")
|
436
439
|
end
|
437
440
|
end
|
438
441
|
|