ninoxe 0.1.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/app/models/chouette/command.rb +3 -2
  2. data/app/models/chouette/route.rb +12 -11
  3. data/app/models/chouette/stop_point.rb +11 -5
  4. data/app/models/chouette/time_table.rb +19 -7
  5. data/app/models/chouette/time_table_date.rb +8 -1
  6. data/app/models/chouette/time_table_period.rb +6 -1
  7. data/app/models/chouette/trident_active_record.rb +12 -0
  8. data/config/database.yml +2 -0
  9. data/{spec/dummy/config/database.yml → config/database.yml.me} +2 -0
  10. data/lib/ninoxe/version.rb +1 -1
  11. data/lib/ninoxe.rb~ +7 -0
  12. metadata +131 -209
  13. checksums.yaml +0 -7
  14. data/spec/dummy/README.rdoc +0 -261
  15. data/spec/dummy/Rakefile +0 -6
  16. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  17. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  18. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  19. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  20. data/spec/dummy/app/mailers/.gitkeep +0 -0
  21. data/spec/dummy/app/models/.gitkeep +0 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  23. data/spec/dummy/config/application.rb +0 -56
  24. data/spec/dummy/config/boot.rb +0 -10
  25. data/spec/dummy/config/environment.rb +0 -7
  26. data/spec/dummy/config/environments/development.rb +0 -37
  27. data/spec/dummy/config/environments/production.rb +0 -67
  28. data/spec/dummy/config/environments/test.rb +0 -37
  29. data/spec/dummy/config/initializers/active_record.rb +0 -2
  30. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  31. data/spec/dummy/config/initializers/inflections.rb +0 -15
  32. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  33. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  34. data/spec/dummy/config/initializers/session_store.rb +0 -8
  35. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  36. data/spec/dummy/config/locales/en.yml +0 -5
  37. data/spec/dummy/config/routes.rb +0 -4
  38. data/spec/dummy/config.ru +0 -4
  39. data/spec/dummy/db/test.sqlite3 +0 -0
  40. data/spec/dummy/lib/assets/.gitkeep +0 -0
  41. data/spec/dummy/log/.gitkeep +0 -0
  42. data/spec/dummy/public/404.html +0 -26
  43. data/spec/dummy/public/422.html +0 -26
  44. data/spec/dummy/public/500.html +0 -25
  45. data/spec/dummy/public/favicon.ico +0 -0
  46. data/spec/dummy/script/rails +0 -6
  47. data/spec/models/chouette/access_link_spec.rb +0 -78
  48. data/spec/models/chouette/access_point_spec.rb +0 -193
  49. data/spec/models/chouette/active_record_spec.rb +0 -121
  50. data/spec/models/chouette/area_type_spec.rb +0 -53
  51. data/spec/models/chouette/company_spec.rb +0 -51
  52. data/spec/models/chouette/connection_link_spec.rb +0 -56
  53. data/spec/models/chouette/direction_spec.rb +0 -60
  54. data/spec/models/chouette/exporter_spec.rb +0 -28
  55. data/spec/models/chouette/file_validator_spec.rb +0 -28
  56. data/spec/models/chouette/group_of_line_spec.rb +0 -31
  57. data/spec/models/chouette/journey_pattern_spec.rb +0 -62
  58. data/spec/models/chouette/line_spec.rb +0 -106
  59. data/spec/models/chouette/loader_spec.rb +0 -69
  60. data/spec/models/chouette/network_spec.rb +0 -22
  61. data/spec/models/chouette/object_id_spec.rb +0 -146
  62. data/spec/models/chouette/route_spec.rb +0 -159
  63. data/spec/models/chouette/stop_area_spec.rb +0 -354
  64. data/spec/models/chouette/stop_point_spec.rb +0 -39
  65. data/spec/models/chouette/time_table_spec.rb +0 -372
  66. data/spec/models/chouette/transport_mode_spec.rb +0 -64
  67. data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +0 -46
  68. data/spec/models/chouette/vehicle_journey_spec.rb +0 -204
  69. data/spec/presenters/chouette/geometry/general_presenter.rb +0 -1
  70. data/spec/presenters/chouette/geometry/line_presenter_spec.rb +0 -13
  71. data/spec/spec_helper.rb +0 -45
@@ -1,159 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::Route do
4
- subject { Factory(:route) }
5
-
6
- it { should validate_uniqueness_of :objectid }
7
- its(:objectid) { should be_kind_of(Chouette::ObjectId) }
8
-
9
- it { should validate_presence_of :name }
10
- it { should validate_presence_of :line }
11
- it { should validate_presence_of :wayback_code }
12
- it { should validate_presence_of :direction_code }
13
-
14
- context "reordering methods" do
15
- let( :bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}}
16
- let( :ident){subject.stop_points.map(&:id)}
17
- let( :first_last_swap){ [ident.last] + ident[1..-2] + [ident.first]}
18
-
19
- describe "#reorder!" do
20
- context "invalid stop_point_ids" do
21
- let( :new_stop_point_ids) { bad_stop_point_ids}
22
- it { subject.reorder!( new_stop_point_ids).should be_false}
23
- end
24
-
25
- context "swaped last and first stop_point_ids" do
26
- let!( :new_stop_point_ids) { first_last_swap}
27
- let!( :old_stop_point_ids) { subject.stop_points.map(&:id) }
28
- let!( :old_stop_area_ids) { subject.stop_areas.map(&:id) }
29
-
30
- it "should keep stop_point_ids order unchanged" do
31
- subject.reorder!( new_stop_point_ids).should be_true
32
- subject.stop_points.map(&:id).should eq( old_stop_point_ids)
33
- end
34
- it "should have changed stop_area_ids order" do
35
- subject.reorder!( new_stop_point_ids).should be_true
36
- subject.reload
37
- subject.stop_areas.map(&:id).should eq( [old_stop_area_ids.last] + old_stop_area_ids[1..-2] + [old_stop_area_ids.first])
38
- end
39
- end
40
- end
41
-
42
- describe "#stop_point_permutation?" do
43
- context "invalid stop_point_ids" do
44
- let( :new_stop_point_ids) { bad_stop_point_ids}
45
- it { should_not be_stop_point_permutation( new_stop_point_ids)}
46
- end
47
- context "unchanged stop_point_ids" do
48
- let( :new_stop_point_ids) { ident}
49
- it { should be_stop_point_permutation( new_stop_point_ids)}
50
- end
51
- context "swaped last and first stop_point_ids" do
52
- let( :new_stop_point_ids) { first_last_swap}
53
- it { should be_stop_point_permutation( new_stop_point_ids)}
54
- end
55
- end
56
- end
57
-
58
- describe "#stop_points" do
59
- context "#find_by_stop_area" do
60
- context "when arg is first quay id" do
61
- let(:first_stop_point) { subject.stop_points.first}
62
- it "should return first quay" do
63
- subject.stop_points.find_by_stop_area( first_stop_point.stop_area_id).should eq( first_stop_point)
64
- end
65
- end
66
- end
67
- end
68
- describe "#stop_areas" do
69
- let(:line){ Factory(:line)}
70
- let(:route_1){ Factory(:route, :line => line)}
71
- let(:route_2){ Factory(:route, :line => line)}
72
- it "should retreive all stop_area on route" do
73
- route_1.stop_areas.each do |sa|
74
- sa.stop_points.map(&:route_id).uniq.should == [route_1.id]
75
- end
76
- end
77
-
78
- context "when route is looping: last and first stop area are the same" do
79
- it "should retreive same stop_area one last and first position" do
80
- route_loop = Factory(:route, :line => line)
81
- first_stop = Chouette::StopPoint.where( :route_id => route_loop.id, :position => 0).first
82
- last_stop = Factory(:stop_point, :route => route_loop, :position => 5, :stop_area => first_stop.stop_area)
83
-
84
- route_loop.stop_areas.size.should == 6
85
- route_loop.stop_areas.select {|s| s.id == first_stop.stop_area.id}.size.should == 2
86
- end
87
- end
88
- end
89
-
90
- describe "#direction_code" do
91
- def self.legacy_directions
92
- %w{A R ClockWise CounterClockWise North NorthWest West SouthWest
93
- South SouthEast East NorthEast}
94
- end
95
- legacy_directions.each do |direction|
96
- context "when direction is #{direction}" do
97
- direction_code = Chouette::Direction.new( Chouette::Route.direction_binding[ direction])
98
- it "should be #{direction_code}" do
99
- subject.direction = direction
100
- subject.direction_code.should == direction_code
101
- end
102
- end
103
- end
104
- context "when direction is nil" do
105
- it "should be nil" do
106
- subject.direction = nil
107
- subject.direction_code.should be_nil
108
- end
109
- end
110
- end
111
- describe "#direction_code=" do
112
- context "when unknown direction is provided" do
113
- it "should change direction to nil" do
114
- subject.direction_code = "dummy"
115
- subject.direction.should be_nil
116
- end
117
- end
118
- context "when an existing direction (west) is provided" do
119
- it "should change direction Direction.west" do
120
- subject.direction_code = "west"
121
- subject.direction.should == "West"
122
- end
123
- end
124
- end
125
- describe "#wayback_code" do
126
- def self.legacy_waybacks
127
- %w{A R}
128
- end
129
- legacy_waybacks.each do |wayback|
130
- context "when wayback is #{wayback}" do
131
- wayback_code = Chouette::Wayback.new( Chouette::Route.wayback_binding[ wayback])
132
- it "should be #{wayback_code}" do
133
- subject.wayback = wayback
134
- subject.wayback_code.should == wayback_code
135
- end
136
- end
137
- end
138
- context "when wayback is nil" do
139
- it "should be nil" do
140
- subject.wayback = nil
141
- subject.wayback_code.should be_nil
142
- end
143
- end
144
- end
145
- describe "#wayback_code=" do
146
- context "when unknown wayback is provided" do
147
- it "should change wayback to nil" do
148
- subject.wayback_code = "dummy"
149
- subject.wayback.should be_nil
150
- end
151
- end
152
- context "when an existing wayback (straight_forward) is provided" do
153
- it "should change wayback Wayback.straight_forward" do
154
- subject.wayback_code = "straight_forward"
155
- subject.wayback.should == "A"
156
- end
157
- end
158
- end
159
- end
@@ -1,354 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::StopArea do
4
- let!(:quay) { Factory :stop_area, :area_type => "Quay" }
5
- let!(:boarding_position) { Factory :stop_area, :area_type => "BoardingPosition" }
6
- let!(:commercial_stop_point) { Factory :stop_area, :area_type => "CommercialStopPoint" }
7
- let!(:stop_place) { Factory :stop_area, :area_type => "StopPlace" }
8
- let!(:itl) { Factory :stop_area, :area_type => "ITL" }
9
-
10
- its(:objectid) { should be_kind_of(Chouette::ObjectId) }
11
-
12
- it { should validate_presence_of :name }
13
- it { should validate_presence_of :area_type }
14
- it { should validate_numericality_of :latitude }
15
- it { should validate_numericality_of :longitude }
16
-
17
-
18
- describe ".latitude" do
19
- it "should accept -90 value" do
20
- subject = Factory :stop_area, :area_type => "BoardingPosition"
21
- subject.latitude = -90
22
- subject.valid?.should be_true
23
- end
24
- it "should reject < -90 value" do
25
- subject = Factory :stop_area, :area_type => "BoardingPosition"
26
- subject.latitude = -90.0001
27
- subject.valid?.should be_false
28
- end
29
- it "should accept 90 value" do
30
- subject = Factory :stop_area, :area_type => "BoardingPosition"
31
- subject.latitude = 90
32
- subject.valid?.should be_true
33
- end
34
- it "should reject > 90 value" do
35
- subject = Factory :stop_area, :area_type => "BoardingPosition"
36
- subject.latitude = 90.0001
37
- subject.valid?.should be_false
38
- end
39
- end
40
-
41
- describe ".longitude" do
42
- it "should accept -180 value" do
43
- subject = Factory :stop_area, :area_type => "BoardingPosition"
44
- subject.longitude = -180
45
- subject.valid?.should be_true
46
- end
47
- it "should reject < -180 value" do
48
- subject = Factory :stop_area, :area_type => "BoardingPosition"
49
- subject.longitude = -180.0001
50
- subject.valid?.should be_false
51
- end
52
- it "should accept 180 value" do
53
- subject = Factory :stop_area, :area_type => "BoardingPosition"
54
- subject.longitude = 180
55
- subject.valid?.should be_true
56
- end
57
- it "should reject > 180 value" do
58
- subject = Factory :stop_area, :area_type => "BoardingPosition"
59
- subject.longitude = 180.0001
60
- subject.valid?.should be_false
61
- end
62
- end
63
-
64
- describe ".long_lat" do
65
- it "should accept longitude and latitude both as nil" do
66
- subject = Factory :stop_area, :area_type => "BoardingPosition"
67
- subject.longitude = nil
68
- subject.latitude = nil
69
- subject.valid?.should be_true
70
- end
71
- it "should accept longitude and latitude both numerical" do
72
- subject = Factory :stop_area, :area_type => "BoardingPosition"
73
- subject.longitude = 10
74
- subject.latitude = 10
75
- subject.valid?.should be_true
76
- end
77
- it "should reject longitude nil with latitude numerical" do
78
- subject = Factory :stop_area, :area_type => "BoardingPosition"
79
- subject.longitude = nil
80
- subject.latitude = 10
81
- subject.valid?.should be_false
82
- end
83
- it "should reject longitude numerical with latitude nil" do
84
- subject = Factory :stop_area, :area_type => "BoardingPosition"
85
- subject.longitude = 10
86
- subject.latitude = nil
87
- subject.valid?.should be_false
88
- end
89
- end
90
-
91
-
92
- describe ".children_in_depth" do
93
- it "should return all the deepest children from stop area" do
94
- subject = Factory :stop_area, :area_type => "StopPlace"
95
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint", :parent => subject
96
- commercial_stop_point2 = Factory :stop_area, :area_type => "CommercialStopPoint", :parent => commercial_stop_point
97
- quay = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
98
- subject.children_in_depth.should =~ [commercial_stop_point, commercial_stop_point2, quay]
99
- end
100
- it "should return only the deepest children from stop area" do
101
- subject = Factory :stop_area, :area_type => "StopPlace"
102
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint", :parent => subject
103
- commercial_stop_point2 = Factory :stop_area, :area_type => "CommercialStopPoint", :parent => commercial_stop_point
104
- quay = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
105
- subject.children_at_base.should =~ [quay]
106
- end
107
- end
108
-
109
- describe ".stop_area_type" do
110
- it "should have area_type of BoardingPosition when stop_area_type is set to boarding_position" do
111
- subject = Factory :stop_area, :stop_area_type => "boarding_position"
112
- subject.area_type.should == "BoardingPosition"
113
- end
114
- it "should have area_type of Quay when stop_area_type is set to quay" do
115
- subject = Factory :stop_area, :stop_area_type => "quay"
116
- subject.area_type.should == "Quay"
117
- end
118
- it "should have area_type of CommercialStopPoint when stop_area_type is set to commercial_stop_point" do
119
- subject = Factory :stop_area, :stop_area_type => "commercial_stop_point"
120
- subject.area_type.should == "CommercialStopPoint"
121
- end
122
- it "should have area_type of StopPlace when stop_area_type is set to stop_place" do
123
- subject = Factory :stop_area, :stop_area_type => "stop_place"
124
- subject.area_type.should == "StopPlace"
125
- end
126
- it "should have area_type of ITL when stop_area_type is set to itl" do
127
- subject = Factory :stop_area, :stop_area_type => "itl"
128
- subject.area_type.should == "ITL"
129
- end
130
- end
131
-
132
- describe ".parent" do
133
- it "should check if parent method exists" do
134
- subject = Factory :stop_area, :parent_id => commercial_stop_point.id
135
- subject.parent.should == commercial_stop_point
136
- end
137
- end
138
-
139
- describe ".possible_children" do
140
-
141
- it "should find no possible descendant for stop area type quay" do
142
- subject = Factory :stop_area, :area_type => "Quay"
143
- subject.possible_children.should == []
144
- end
145
-
146
- it "should find no possible descendant for stop area type boarding position" do
147
- subject = Factory :stop_area, :area_type => "BoardingPosition"
148
- subject.possible_children.should == []
149
- end
150
-
151
- it "should find descendant of type quay or boarding position for stop area type commercial stop point" do
152
- subject = Factory :stop_area, :area_type => "CommercialStopPoint"
153
- subject.possible_children.should =~ [quay, boarding_position]
154
- end
155
-
156
- it "should find no children of type stop place or commercial stop point for stop area type stop place" do
157
- subject = Factory :stop_area, :area_type => "StopPlace"
158
- subject.possible_children.should =~ [stop_place, commercial_stop_point]
159
- end
160
-
161
- it "should find no children of type ITL for stop area type ITL" do
162
- subject = Factory :stop_area, :area_type => "ITL"
163
- subject.possible_children.should =~ [stop_place, commercial_stop_point, quay, boarding_position]
164
- end
165
-
166
- end
167
-
168
- describe ".possible_parents" do
169
-
170
- it "should find parent type commercial stop point for stop area type boarding position" do
171
- subject = Factory :stop_area, :area_type => "BoardingPosition"
172
- subject.possible_parents.should == [commercial_stop_point]
173
- end
174
-
175
- it "should find parent type commercial stop point for stop area type quay" do
176
- subject = Factory :stop_area, :area_type => "Quay"
177
- subject.possible_parents.should == [commercial_stop_point]
178
- end
179
-
180
- it "should find parent type stop place for stop area type commercial stop point" do
181
- subject = Factory :stop_area, :area_type => "CommercialStopPoint"
182
- subject.possible_parents.should == [stop_place]
183
- end
184
-
185
- it "should find parent type stop place for stop area type stop place" do
186
- subject = Factory :stop_area, :area_type => "StopPlace"
187
- subject.possible_parents.should == [stop_place]
188
- end
189
-
190
- end
191
-
192
-
193
- describe ".near" do
194
-
195
- let(:stop_area) { Factory :stop_area, :latitude => 1, :longitude => 1 }
196
- let(:stop_area2) { Factory :stop_area, :latitude => 1, :longitude => 1 }
197
-
198
- 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)).should == [stop_area]
200
- end
201
-
202
- 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)).should be_empty
204
- end
205
-
206
- end
207
-
208
- describe "#to_lat_lng" do
209
-
210
- it "should return nil if latitude is nil" do
211
- subject.latitude = nil
212
- subject.to_lat_lng.should be_nil
213
- end
214
-
215
- it "should return nil if longitude is nil" do
216
- subject.longitude = nil
217
- subject.to_lat_lng.should be_nil
218
- end
219
-
220
- end
221
-
222
- describe "#geometry" do
223
-
224
- it "should be nil when to_lat_lng is nil" do
225
- subject.stub :to_lat_lng => nil
226
- subject.geometry.should be_nil
227
- end
228
-
229
- end
230
-
231
- describe ".bounds" do
232
-
233
- it "should return transform coordinates in floats" do
234
- Chouette::StopArea.connection.stub :select_rows => [["113.5292500000000000", "22.1127580000000000", "113.5819330000000000", "22.2157050000000000"]]
235
- GeoRuby::SimpleFeatures::Envelope.should_receive(:from_coordinates).with([[113.5292500000000000, 22.1127580000000000], [113.5819330000000000, 22.2157050000000000]])
236
- Chouette::StopArea.bounds
237
- end
238
-
239
- end
240
-
241
- describe "#default_position" do
242
-
243
- it "should return nil when StopArea.bounds is nil" do
244
- Chouette::StopArea.stub :bounds => nil
245
- subject.default_position.should be_nil
246
- end
247
-
248
- it "should return StopArea.bounds center" do
249
- Chouette::StopArea.stub :bounds => mock(:center => "center")
250
- subject.default_position.should == Chouette::StopArea.bounds.center
251
- end
252
-
253
- end
254
-
255
- describe "#children_at_base" do
256
- it "should have 2 children_at_base" do
257
- subject = Factory :stop_area, :area_type => "StopPlace"
258
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
259
- quay1 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
260
- quay2 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
261
- subject.children_at_base.size.should == 2
262
- end
263
- end
264
-
265
-
266
- describe "#generic_access_link_matrix" do
267
- it "should have no access_links in matrix with no access_point" do
268
- subject = Factory :stop_area, :area_type => "StopPlace"
269
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
270
- subject.generic_access_link_matrix.size.should == 0
271
- end
272
- it "should have 4 generic_access_links in matrix with 2 access_points" do
273
- subject = Factory :stop_area, :area_type => "StopPlace"
274
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
275
- access_point1 = Factory :access_point, :stop_area => subject
276
- access_point2 = Factory :access_point, :stop_area => subject
277
- subject.generic_access_link_matrix.size.should == 4
278
- end
279
- end
280
- describe "#detail_access_link_matrix" do
281
- it "should have no access_links in matrix with no access_point" do
282
- subject = Factory :stop_area, :area_type => "StopPlace"
283
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
284
- quay1 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
285
- quay2 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
286
- subject.detail_access_link_matrix.size.should == 0
287
- end
288
- it "should have 8 detail_access_links in matrix with 2 children_at_base and 2 access_points" do
289
- subject = Factory :stop_area, :area_type => "StopPlace"
290
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => subject
291
- quay1 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
292
- quay2 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
293
- access_point1 = Factory :access_point, :stop_area => subject
294
- access_point2 = Factory :access_point, :stop_area => subject
295
- subject.detail_access_link_matrix.size.should == 8
296
- end
297
- end
298
- describe "#parents" do
299
- it "should return parent hireachy list" do
300
- stop_place = Factory :stop_area, :area_type => "StopPlace"
301
- commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
302
- subject = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
303
- subject.parents.size.should == 2
304
- end
305
- it "should return empty parent hireachy list" do
306
- subject = Factory :stop_area, :area_type => "Quay"
307
- subject.parents.size.should == 0
308
- end
309
- end
310
-
311
- describe "#clean_invalid_access_links" do
312
- it "should remove invalid access links" do
313
- # subject is a CSP with a SP as parent, a quay as child
314
- # 2 access_points of SP have access_link, one on subject, one on subject child
315
- # when detaching subject from SP, both access_links must be deleted
316
- stop_place = Factory :stop_area, :area_type => "StopPlace"
317
- subject = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
318
- access_point1 = Factory :access_point, :stop_area => stop_place
319
- access_point2 = Factory :access_point, :stop_area => stop_place
320
- quay = Factory :stop_area, :parent => subject, :area_type => "Quay"
321
- access_link1 = Factory :access_link, :stop_area => subject, :access_point => access_point1
322
- access_link2 = Factory :access_link, :stop_area => quay, :access_point => access_point2
323
- subject.save
324
- subject.access_links.size.should == 1
325
- quay.access_links.size.should == 1
326
- subject.parent=nil
327
- subject.save
328
- subject.reload
329
- subject.access_links.size.should == 0
330
- quay.access_links.size.should == 0
331
- end
332
- it "should not remove still valid access links" do
333
- # subject is a Q of CSP with a SP as parent
334
- # 2 access_points, one of SP, one of CSP have access_link on subject
335
- # when changing subject CSP to another CSP of same SP
336
- # one access_links must be kept
337
- stop_place = Factory :stop_area, :area_type => "StopPlace"
338
- commercial_stop_point1 = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
339
- commercial_stop_point2 = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
340
- access_point1 = Factory :access_point, :stop_area => stop_place
341
- access_point2 = Factory :access_point, :stop_area => commercial_stop_point1
342
- subject = Factory :stop_area, :parent => commercial_stop_point1, :area_type => "Quay"
343
- access_link1 = Factory :access_link, :stop_area => subject, :access_point => access_point1
344
- access_link2 = Factory :access_link, :stop_area => subject, :access_point => access_point2
345
- subject.save
346
- subject.access_links.size.should == 2
347
- subject.parent=commercial_stop_point2
348
- subject.save
349
- subject.reload
350
- subject.access_links.size.should == 1
351
- end
352
- end
353
-
354
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::StopPoint do
4
- let!(:vehicle_journey) { Factory(:vehicle_journey)}
5
- subject { Chouette::Route.find( vehicle_journey.route_id).stop_points.first }
6
-
7
- it { should validate_uniqueness_of :objectid }
8
- it { should validate_presence_of :stop_area }
9
- it { should validate_presence_of :route }
10
-
11
- its(:objectid) { should be_kind_of(Chouette::ObjectId) }
12
-
13
- describe "#destroy" do
14
- before(:each) do
15
- @vehicle = Factory(:vehicle_journey)
16
- @stop_point = Chouette::Route.find( @vehicle.route_id).stop_points.first
17
- end
18
- def vjas_stop_point_ids( vehicle_id)
19
- Chouette::VehicleJourney.find( vehicle_id).vehicle_journey_at_stops.map(&:stop_point_id)
20
- end
21
- def jpsp_stop_point_ids( journey_id)
22
- Chouette::JourneyPattern.find( journey_id).stop_points.map(&:id)
23
- end
24
- it "should remove dependent vehicle_journey_at_stop" do
25
- vjas_stop_point_ids(@vehicle.id).should include(@stop_point.id)
26
-
27
- @stop_point.destroy
28
-
29
- vjas_stop_point_ids(@vehicle.id).should_not include(@stop_point.id)
30
- end
31
- it "should remove dependent journey_pattern_stop_point" do
32
- jpsp_stop_point_ids(@vehicle.journey_pattern_id).should include(@stop_point.id)
33
-
34
- @stop_point.destroy
35
-
36
- jpsp_stop_point_ids(@vehicle.journey_pattern_id).should_not include(@stop_point.id)
37
- end
38
- end
39
- end