ninoxe 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/app/models/chouette/company.rb +3 -4
- data/app/models/chouette/line.rb +0 -1
- data/app/models/chouette/network.rb +4 -5
- data/app/models/chouette/stop_area.rb +25 -26
- data/config/database.yml.me +11 -0
- data/db/migrate/20150630135517_remove_uniqueness_for_registration_number.rb +22 -0
- data/lib/ninoxe.rb~ +7 -0
- data/lib/ninoxe/version.rb +1 -1
- metadata +45 -212
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -28
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -19
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -29
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/locales/fr.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/db/schema.rb +0 -489
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +0 -58
- data/spec/dummy/public/422.html +0 -58
- data/spec/dummy/public/500.html +0 -57
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/factories/chouette_access_links.rb +0 -13
- data/spec/factories/chouette_access_points.rb +0 -12
- data/spec/factories/chouette_companies.rb +0 -9
- data/spec/factories/chouette_connection_links.rb +0 -13
- data/spec/factories/chouette_footnotes.rb +0 -10
- data/spec/factories/chouette_group_of_lines.rb +0 -9
- data/spec/factories/chouette_journey_pattern.rb +0 -40
- data/spec/factories/chouette_lines.rb +0 -44
- data/spec/factories/chouette_networks.rb +0 -9
- data/spec/factories/chouette_routes.rb +0 -26
- data/spec/factories/chouette_stop_areas.rb +0 -12
- data/spec/factories/chouette_stop_points.rb +0 -10
- data/spec/factories/chouette_time_table.rb +0 -37
- data/spec/factories/chouette_vehicle_journey.rb +0 -66
- data/spec/factories/chouette_vehicle_journey_at_stop.rb +0 -8
- data/spec/models/chouette/access_link_spec.rb +0 -82
- data/spec/models/chouette/access_point_spec.rb +0 -269
- data/spec/models/chouette/active_record_spec.rb +0 -121
- data/spec/models/chouette/area_type_spec.rb +0 -53
- data/spec/models/chouette/company_spec.rb +0 -51
- data/spec/models/chouette/connection_link_spec.rb +0 -60
- data/spec/models/chouette/direction_spec.rb +0 -60
- data/spec/models/chouette/exporter_spec.rb +0 -28
- data/spec/models/chouette/file_validator_spec.rb +0 -28
- data/spec/models/chouette/footnote_spec.rb +0 -9
- data/spec/models/chouette/group_of_line_spec.rb +0 -31
- data/spec/models/chouette/journey_pattern_spec.rb +0 -64
- data/spec/models/chouette/line_spec.rb +0 -123
- data/spec/models/chouette/loader_spec.rb +0 -69
- data/spec/models/chouette/network_spec.rb +0 -22
- data/spec/models/chouette/object_id_spec.rb +0 -149
- data/spec/models/chouette/route_spec.rb +0 -238
- data/spec/models/chouette/stop_area_spec.rb +0 -443
- data/spec/models/chouette/stop_point_spec.rb +0 -41
- data/spec/models/chouette/time_table_period_spec.rb +0 -66
- data/spec/models/chouette/time_table_spec.rb +0 -1266
- data/spec/models/chouette/transport_mode_spec.rb +0 -64
- data/spec/models/chouette/trident_active_record_spec.rb +0 -115
- data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +0 -47
- data/spec/models/chouette/vehicle_journey_spec.rb +0 -223
- data/spec/presenters/chouette/geometry/general_presenter.rb +0 -1
- data/spec/presenters/chouette/geometry/line_presenter_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -58
@@ -1,443 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
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
|
14
|
-
|
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 }
|
19
|
-
|
20
|
-
|
21
|
-
describe ".latitude" do
|
22
|
-
it "should accept -90 value" do
|
23
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
24
|
-
subject.latitude = -90
|
25
|
-
expect(subject.valid?).to be_truthy
|
26
|
-
end
|
27
|
-
it "should reject < -90 value" do
|
28
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
29
|
-
subject.latitude = -90.0001
|
30
|
-
expect(subject.valid?).to be_falsey
|
31
|
-
end
|
32
|
-
it "should accept 90 value" do
|
33
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
34
|
-
subject.latitude = 90
|
35
|
-
expect(subject.valid?).to be_truthy
|
36
|
-
end
|
37
|
-
it "should reject > 90 value" do
|
38
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
39
|
-
subject.latitude = 90.0001
|
40
|
-
expect(subject.valid?).to be_falsey
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe ".longitude" do
|
45
|
-
it "should accept -180 value" do
|
46
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
47
|
-
subject.longitude = -180
|
48
|
-
expect(subject.valid?).to be_truthy
|
49
|
-
end
|
50
|
-
it "should reject < -180 value" do
|
51
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
52
|
-
subject.longitude = -180.0001
|
53
|
-
expect(subject.valid?).to be_falsey
|
54
|
-
end
|
55
|
-
it "should accept 180 value" do
|
56
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
57
|
-
subject.longitude = 180
|
58
|
-
expect(subject.valid?).to be_truthy
|
59
|
-
end
|
60
|
-
it "should reject > 180 value" do
|
61
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
62
|
-
subject.longitude = 180.0001
|
63
|
-
expect(subject.valid?).to be_falsey
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe ".long_lat" do
|
68
|
-
it "should accept longitude and latitude both as nil" do
|
69
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
70
|
-
subject.longitude = nil
|
71
|
-
subject.latitude = nil
|
72
|
-
expect(subject.valid?).to be_truthy
|
73
|
-
end
|
74
|
-
it "should accept longitude and latitude both numerical" do
|
75
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
76
|
-
subject.longitude = 10
|
77
|
-
subject.latitude = 10
|
78
|
-
expect(subject.valid?).to be_truthy
|
79
|
-
end
|
80
|
-
it "should reject longitude nil with latitude numerical" do
|
81
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
82
|
-
subject.longitude = nil
|
83
|
-
subject.latitude = 10
|
84
|
-
expect(subject.valid?).to be_falsey
|
85
|
-
end
|
86
|
-
it "should reject longitude numerical with latitude nil" do
|
87
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
88
|
-
subject.longitude = 10
|
89
|
-
subject.latitude = nil
|
90
|
-
expect(subject.valid?).to be_falsey
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
describe ".children_in_depth" do
|
96
|
-
it "should return all the deepest children from stop area" do
|
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])
|
102
|
-
end
|
103
|
-
it "should return only the deepest children from stop area" do
|
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])
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe ".stop_area_type" do
|
113
|
-
it "should have area_type of BoardingPosition when stop_area_type is set to boarding_position" do
|
114
|
-
subject = create :stop_area, :stop_area_type => "boarding_position"
|
115
|
-
expect(subject.area_type).to eq("BoardingPosition")
|
116
|
-
end
|
117
|
-
it "should have area_type of Quay when stop_area_type is set to quay" do
|
118
|
-
subject = create :stop_area, :stop_area_type => "quay"
|
119
|
-
expect(subject.area_type).to eq("Quay")
|
120
|
-
end
|
121
|
-
it "should have area_type of CommercialStopPoint when stop_area_type is set to commercial_stop_point" do
|
122
|
-
subject = create :stop_area, :stop_area_type => "commercial_stop_point"
|
123
|
-
expect(subject.area_type).to eq("CommercialStopPoint")
|
124
|
-
end
|
125
|
-
it "should have area_type of StopPlace when stop_area_type is set to stop_place" do
|
126
|
-
subject = create :stop_area, :stop_area_type => "stop_place"
|
127
|
-
expect(subject.area_type).to eq("StopPlace")
|
128
|
-
end
|
129
|
-
it "should have area_type of ITL when stop_area_type is set to itl" do
|
130
|
-
subject = create :stop_area, :stop_area_type => "itl"
|
131
|
-
expect(subject.area_type).to eq("ITL")
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe ".parent" do
|
136
|
-
it "should check if parent method exists" do
|
137
|
-
subject = create :stop_area, :parent_id => commercial_stop_point.id
|
138
|
-
expect(subject.parent).to eq(commercial_stop_point)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe ".possible_children" do
|
143
|
-
|
144
|
-
it "should find no possible descendant for stop area type quay" do
|
145
|
-
subject = create :stop_area, :area_type => "Quay"
|
146
|
-
expect(subject.possible_children).to eq([])
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should find no possible descendant for stop area type boarding position" do
|
150
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
151
|
-
expect(subject.possible_children).to eq([])
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should find descendant of type quay or boarding position for stop area type commercial stop point" do
|
155
|
-
subject = create :stop_area, :area_type => "CommercialStopPoint"
|
156
|
-
expect(subject.possible_children).to match_array([quay, boarding_position])
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should find no children of type stop place or commercial stop point for stop area type stop place" do
|
160
|
-
subject = create :stop_area, :area_type => "StopPlace"
|
161
|
-
expect(subject.possible_children).to match_array([stop_place, commercial_stop_point])
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should find no children of type ITL for stop area type ITL" do
|
165
|
-
subject = create :stop_area, :area_type => "ITL"
|
166
|
-
expect(subject.possible_children).to match_array([stop_place, commercial_stop_point, quay, boarding_position])
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
describe ".possible_parents" do
|
172
|
-
|
173
|
-
it "should find parent type commercial stop point for stop area type boarding position" do
|
174
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
175
|
-
expect(subject.possible_parents).to eq([commercial_stop_point])
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should find parent type commercial stop point for stop area type quay" do
|
179
|
-
subject = create :stop_area, :area_type => "Quay"
|
180
|
-
expect(subject.possible_parents).to eq([commercial_stop_point])
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should find parent type stop place for stop area type commercial stop point" do
|
184
|
-
subject = create :stop_area, :area_type => "CommercialStopPoint"
|
185
|
-
expect(subject.possible_parents).to eq([stop_place])
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should find parent type stop place for stop area type stop place" do
|
189
|
-
subject = create :stop_area, :area_type => "StopPlace"
|
190
|
-
expect(subject.possible_parents).to eq([stop_place])
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
194
|
-
|
195
|
-
|
196
|
-
describe ".near" do
|
197
|
-
|
198
|
-
let(:stop_area) { create :stop_area, :latitude => 1, :longitude => 1 }
|
199
|
-
let(:stop_area2) { create :stop_area, :latitude => 1, :longitude => 1 }
|
200
|
-
|
201
|
-
it "should find a StopArea at 300m from given origin" do
|
202
|
-
expect(Chouette::StopArea.near(stop_area.to_lat_lng.endpoint(0, 0.250, :units => :kms))).to eq([stop_area])
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should not find a StopArea at more than 300m from given origin" do
|
206
|
-
expect(Chouette::StopArea.near(stop_area2.to_lat_lng.endpoint(0, 0.350, :units => :kms))).to be_empty
|
207
|
-
end
|
208
|
-
|
209
|
-
end
|
210
|
-
|
211
|
-
describe "#to_lat_lng" do
|
212
|
-
|
213
|
-
it "should return nil if latitude is nil" do
|
214
|
-
subject.latitude = nil
|
215
|
-
expect(subject.to_lat_lng).to be_nil
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should return nil if longitude is nil" do
|
219
|
-
subject.longitude = nil
|
220
|
-
expect(subject.to_lat_lng).to be_nil
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "#geometry" do
|
226
|
-
|
227
|
-
it "should be nil when to_lat_lng is nil" do
|
228
|
-
allow(subject).to receive_messages :to_lat_lng => nil
|
229
|
-
expect(subject.geometry).to be_nil
|
230
|
-
end
|
231
|
-
|
232
|
-
end
|
233
|
-
|
234
|
-
describe ".bounds" do
|
235
|
-
|
236
|
-
it "should return transform coordinates in floats" do
|
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]])
|
239
|
-
Chouette::StopArea.bounds
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
describe "#default_position" do
|
245
|
-
|
246
|
-
it "should return nil when StopArea.bounds is nil" do
|
247
|
-
allow(Chouette::StopArea).to receive_messages :bounds => nil
|
248
|
-
expect(subject.default_position).to be_nil
|
249
|
-
end
|
250
|
-
|
251
|
-
it "should return StopArea.bounds center" do
|
252
|
-
allow(Chouette::StopArea).to receive_messages :bounds => double(:center => "center")
|
253
|
-
expect(subject.default_position).to eq(Chouette::StopArea.bounds.center)
|
254
|
-
end
|
255
|
-
|
256
|
-
end
|
257
|
-
|
258
|
-
describe "#children_at_base" do
|
259
|
-
it "should have 2 children_at_base" do
|
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)
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
|
269
|
-
describe "#generic_access_link_matrix" do
|
270
|
-
it "should have no access_links in matrix with no access_point" do
|
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)
|
274
|
-
end
|
275
|
-
it "should have 4 generic_access_links in matrix with 2 access_points" do
|
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)
|
281
|
-
end
|
282
|
-
end
|
283
|
-
describe "#detail_access_link_matrix" do
|
284
|
-
it "should have no access_links in matrix with no access_point" do
|
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)
|
290
|
-
end
|
291
|
-
it "should have 8 detail_access_links in matrix with 2 children_at_base and 2 access_points" do
|
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)
|
299
|
-
end
|
300
|
-
end
|
301
|
-
describe "#parents" do
|
302
|
-
it "should return parent hireachy list" do
|
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)
|
307
|
-
end
|
308
|
-
it "should return empty parent hireachy list" do
|
309
|
-
subject = create :stop_area, :area_type => "Quay"
|
310
|
-
expect(subject.parents.size).to eq(0)
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
describe "#clean_invalid_access_links" do
|
315
|
-
it "should remove invalid access links" do
|
316
|
-
# subject is a CSP with a SP as parent, a quay as child
|
317
|
-
# 2 access_points of SP have access_link, one on subject, one on subject child
|
318
|
-
# when detaching subject from SP, both access_links must be deleted
|
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
|
326
|
-
subject.save
|
327
|
-
expect(subject.access_links.size).to eq(1)
|
328
|
-
expect(quay.access_links.size).to eq(1)
|
329
|
-
subject.parent=nil
|
330
|
-
subject.save
|
331
|
-
subject.reload
|
332
|
-
expect(subject.access_links.size).to eq(0)
|
333
|
-
expect(quay.access_links.size).to eq(0)
|
334
|
-
end
|
335
|
-
it "should not remove still valid access links" do
|
336
|
-
# subject is a Q of CSP with a SP as parent
|
337
|
-
# 2 access_points, one of SP, one of CSP have access_link on subject
|
338
|
-
# when changing subject CSP to another CSP of same SP
|
339
|
-
# one access_links must be kept
|
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
|
348
|
-
subject.save
|
349
|
-
expect(subject.access_links.size).to eq(2)
|
350
|
-
subject.parent=commercial_stop_point2
|
351
|
-
subject.save
|
352
|
-
subject.reload
|
353
|
-
expect(subject.access_links.size).to eq(1)
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
describe "#coordinates" do
|
358
|
-
it "should convert coordinates into latitude/longitude" do
|
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)
|
362
|
-
end
|
363
|
-
it "should set empty coordinates into nil latitude/longitude" do
|
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)
|
367
|
-
subject.coordinates = ""
|
368
|
-
subject.save
|
369
|
-
expect(subject.longitude).to be_nil
|
370
|
-
expect(subject.latitude).to be_nil
|
371
|
-
end
|
372
|
-
it "should convert latitude/longitude into coordinates" do
|
373
|
-
subject = create :stop_area, :area_type => "BoardingPosition", :longitude => 120.456, :latitude => 45.123
|
374
|
-
expect(subject.coordinates).to eq("45.123,120.456")
|
375
|
-
end
|
376
|
-
it "should convert nil latitude/longitude into empty coordinates" do
|
377
|
-
subject = create :stop_area, :area_type => "BoardingPosition", :longitude => nil, :latitude => nil
|
378
|
-
expect(subject.coordinates).to eq("")
|
379
|
-
end
|
380
|
-
it "should accept valid coordinates" do
|
381
|
-
subject = create :stop_area, :area_type => "BoardingPosition", :coordinates => "45.123,120.456"
|
382
|
-
expect(subject.valid?).to be_truthy
|
383
|
-
subject.coordinates = "45.123, 120.456"
|
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)
|
387
|
-
subject.coordinates = "45.123, -120.456"
|
388
|
-
expect(subject.valid?).to be_truthy
|
389
|
-
subject.coordinates = "45.123 ,120.456"
|
390
|
-
expect(subject.valid?).to be_truthy
|
391
|
-
subject.coordinates = "45.123 , 120.456"
|
392
|
-
expect(subject.valid?).to be_truthy
|
393
|
-
subject.coordinates = " 45.123,120.456"
|
394
|
-
expect(subject.valid?).to be_truthy
|
395
|
-
subject.coordinates = "45.123,120.456 "
|
396
|
-
expect(subject.valid?).to be_truthy
|
397
|
-
end
|
398
|
-
it "should accept valid coordinates on limits" do
|
399
|
-
subject = create :stop_area, :area_type => "BoardingPosition", :coordinates => "90,180"
|
400
|
-
expect(subject.valid?).to be_truthy
|
401
|
-
subject.coordinates = "-90,-180"
|
402
|
-
expect(subject.valid?).to be_truthy
|
403
|
-
subject.coordinates = "-90.,180."
|
404
|
-
expect(subject.valid?).to be_truthy
|
405
|
-
subject.coordinates = "-90.0,180.00"
|
406
|
-
expect(subject.valid?).to be_truthy
|
407
|
-
end
|
408
|
-
it "should reject invalid coordinates" do
|
409
|
-
subject = create :stop_area, :area_type => "BoardingPosition"
|
410
|
-
subject.coordinates = ",12"
|
411
|
-
expect(subject.valid?).to be_falsey
|
412
|
-
subject.coordinates = "-90"
|
413
|
-
expect(subject.valid?).to be_falsey
|
414
|
-
subject.coordinates = "-90.1,180."
|
415
|
-
expect(subject.valid?).to be_falsey
|
416
|
-
subject.coordinates = "-90.0,180.1"
|
417
|
-
expect(subject.valid?).to be_falsey
|
418
|
-
subject.coordinates = "-91.0,18.1"
|
419
|
-
expect(subject.valid?).to be_falsey
|
420
|
-
end
|
421
|
-
end
|
422
|
-
|
423
|
-
describe "#duplicate" do
|
424
|
-
it "should be a copy of" do
|
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"
|
430
|
-
target=subject.duplicate
|
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")
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
|
443
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Chouette::StopPoint, :type => :model do
|
4
|
-
let!(:vehicle_journey) { create(:vehicle_journey)}
|
5
|
-
subject { Chouette::Route.find( vehicle_journey.route_id).stop_points.first }
|
6
|
-
|
7
|
-
it { is_expected.to validate_uniqueness_of :objectid }
|
8
|
-
it { is_expected.to validate_presence_of :stop_area }
|
9
|
-
|
10
|
-
describe '#objectid' do
|
11
|
-
subject { super().objectid }
|
12
|
-
it { is_expected.to be_kind_of(Chouette::ObjectId) }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#destroy" do
|
16
|
-
before(:each) do
|
17
|
-
@vehicle = create(:vehicle_journey)
|
18
|
-
@stop_point = Chouette::Route.find( @vehicle.route_id).stop_points.first
|
19
|
-
end
|
20
|
-
def vjas_stop_point_ids( vehicle_id)
|
21
|
-
Chouette::VehicleJourney.find( vehicle_id).vehicle_journey_at_stops.map(&:stop_point_id)
|
22
|
-
end
|
23
|
-
def jpsp_stop_point_ids( journey_id)
|
24
|
-
Chouette::JourneyPattern.find( journey_id).stop_points.map(&:id)
|
25
|
-
end
|
26
|
-
it "should remove dependent vehicle_journey_at_stop" do
|
27
|
-
expect(vjas_stop_point_ids(@vehicle.id)).to include(@stop_point.id)
|
28
|
-
|
29
|
-
@stop_point.destroy
|
30
|
-
|
31
|
-
expect(vjas_stop_point_ids(@vehicle.id)).not_to include(@stop_point.id)
|
32
|
-
end
|
33
|
-
it "should remove dependent journey_pattern_stop_point" do
|
34
|
-
expect(jpsp_stop_point_ids(@vehicle.journey_pattern_id)).to include(@stop_point.id)
|
35
|
-
|
36
|
-
@stop_point.destroy
|
37
|
-
|
38
|
-
expect(jpsp_stop_point_ids(@vehicle.journey_pattern_id)).not_to include(@stop_point.id)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|