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,83 +1,86 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::AccessPoint do
|
3
|
+
describe Chouette::AccessPoint, :type => :model do
|
4
4
|
|
5
|
-
|
5
|
+
describe '#objectid' do
|
6
|
+
subject { super().objectid }
|
7
|
+
it { is_expected.to be_kind_of(Chouette::ObjectId) }
|
8
|
+
end
|
6
9
|
|
7
|
-
it {
|
8
|
-
it {
|
9
|
-
it {
|
10
|
+
it { is_expected.to validate_presence_of :name }
|
11
|
+
it { is_expected.to validate_numericality_of :latitude }
|
12
|
+
it { is_expected.to validate_numericality_of :longitude }
|
10
13
|
|
11
14
|
describe ".latitude" do
|
12
15
|
it "should accept -90 value" do
|
13
|
-
subject =
|
16
|
+
subject = create :access_point
|
14
17
|
subject.latitude = -90
|
15
|
-
subject.valid
|
18
|
+
expect(subject.valid?).to be_truthy
|
16
19
|
end
|
17
20
|
it "should reject < -90 value" do
|
18
|
-
subject =
|
21
|
+
subject = create :access_point
|
19
22
|
subject.latitude = -90.0001
|
20
|
-
subject.valid
|
23
|
+
expect(subject.valid?).to be_falsey
|
21
24
|
end
|
22
25
|
it "should accept 90 value" do
|
23
|
-
subject =
|
26
|
+
subject = create :access_point
|
24
27
|
subject.latitude = 90
|
25
|
-
subject.valid
|
28
|
+
expect(subject.valid?).to be_truthy
|
26
29
|
end
|
27
30
|
it "should reject > 90 value" do
|
28
|
-
subject =
|
31
|
+
subject = create :access_point
|
29
32
|
subject.latitude = 90.0001
|
30
|
-
subject.valid
|
33
|
+
expect(subject.valid?).to be_falsey
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
34
37
|
describe ".longitude" do
|
35
38
|
it "should accept -180 value" do
|
36
|
-
subject =
|
39
|
+
subject = create :access_point
|
37
40
|
subject.longitude = -180
|
38
|
-
subject.valid
|
41
|
+
expect(subject.valid?).to be_truthy
|
39
42
|
end
|
40
43
|
it "should reject < -180 value" do
|
41
|
-
subject =
|
44
|
+
subject = create :access_point
|
42
45
|
subject.longitude = -180.0001
|
43
|
-
subject.valid
|
46
|
+
expect(subject.valid?).to be_falsey
|
44
47
|
end
|
45
48
|
it "should accept 180 value" do
|
46
|
-
subject =
|
49
|
+
subject = create :access_point
|
47
50
|
subject.longitude = 180
|
48
|
-
subject.valid
|
51
|
+
expect(subject.valid?).to be_truthy
|
49
52
|
end
|
50
53
|
it "should reject > 180 value" do
|
51
|
-
subject =
|
54
|
+
subject = create :access_point
|
52
55
|
subject.longitude = 180.0001
|
53
|
-
subject.valid
|
56
|
+
expect(subject.valid?).to be_falsey
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
60
|
describe ".long_lat" do
|
58
61
|
it "should accept longitude and latitude both as nil" do
|
59
|
-
subject =
|
62
|
+
subject = create :access_point
|
60
63
|
subject.longitude = nil
|
61
64
|
subject.latitude = nil
|
62
|
-
subject.valid
|
65
|
+
expect(subject.valid?).to be_truthy
|
63
66
|
end
|
64
67
|
it "should accept longitude and latitude both numerical" do
|
65
|
-
subject =
|
68
|
+
subject = create :access_point
|
66
69
|
subject.longitude = 10
|
67
70
|
subject.latitude = 10
|
68
|
-
subject.valid
|
71
|
+
expect(subject.valid?).to be_truthy
|
69
72
|
end
|
70
73
|
it "should reject longitude nil with latitude numerical" do
|
71
|
-
subject =
|
74
|
+
subject = create :access_point
|
72
75
|
subject.longitude = nil
|
73
76
|
subject.latitude = 10
|
74
|
-
subject.valid
|
77
|
+
expect(subject.valid?).to be_falsey
|
75
78
|
end
|
76
79
|
it "should reject longitude numerical with latitude nil" do
|
77
|
-
subject =
|
80
|
+
subject = create :access_point
|
78
81
|
subject.longitude = 10
|
79
82
|
subject.latitude = nil
|
80
|
-
subject.valid
|
83
|
+
expect(subject.valid?).to be_falsey
|
81
84
|
end
|
82
85
|
end
|
83
86
|
|
@@ -91,7 +94,7 @@ describe Chouette::AccessPoint do
|
|
91
94
|
access_point_type = Chouette::AccessPointType.new(access_type.underscore)
|
92
95
|
it "should be #{access_point_type}" do
|
93
96
|
subject.access_type = access_type
|
94
|
-
subject.access_point_type.
|
97
|
+
expect(subject.access_point_type).to eq(access_point_type)
|
95
98
|
end
|
96
99
|
end
|
97
100
|
end
|
@@ -100,7 +103,7 @@ describe Chouette::AccessPoint do
|
|
100
103
|
describe "#access_point_type=" do
|
101
104
|
it "should change access_type with Chouette::AccessPointType#name" do
|
102
105
|
subject.access_point_type = "in_out"
|
103
|
-
subject.access_type.
|
106
|
+
expect(subject.access_type).to eq("InOut")
|
104
107
|
end
|
105
108
|
|
106
109
|
end
|
@@ -109,12 +112,12 @@ describe Chouette::AccessPoint do
|
|
109
112
|
|
110
113
|
it "should return nil if latitude is nil" do
|
111
114
|
subject.latitude = nil
|
112
|
-
subject.to_lat_lng.
|
115
|
+
expect(subject.to_lat_lng).to be_nil
|
113
116
|
end
|
114
117
|
|
115
118
|
it "should return nil if longitude is nil" do
|
116
119
|
subject.longitude = nil
|
117
|
-
subject.to_lat_lng.
|
120
|
+
expect(subject.to_lat_lng).to be_nil
|
118
121
|
end
|
119
122
|
|
120
123
|
end
|
@@ -122,36 +125,36 @@ describe Chouette::AccessPoint do
|
|
122
125
|
describe "#geometry" do
|
123
126
|
|
124
127
|
it "should be nil when to_lat_lng is nil" do
|
125
|
-
subject.
|
126
|
-
subject.geometry.
|
128
|
+
allow(subject).to receive_messages :to_lat_lng => nil
|
129
|
+
expect(subject.geometry).to be_nil
|
127
130
|
end
|
128
131
|
|
129
132
|
end
|
130
133
|
|
131
134
|
describe "#generic_access_link_matrix" do
|
132
135
|
it "should have 2 generic_access_links in matrix" do
|
133
|
-
stop_place =
|
134
|
-
commercial_stop_point =
|
135
|
-
subject =
|
136
|
-
subject.generic_access_link_matrix.size.
|
136
|
+
stop_place = create :stop_area, :area_type => "StopPlace"
|
137
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
|
138
|
+
subject = create :access_point, :stop_area => stop_place
|
139
|
+
expect(subject.generic_access_link_matrix.size).to eq(2)
|
137
140
|
end
|
138
141
|
|
139
142
|
it "should have new generic_access_links in matrix" do
|
140
|
-
commercial_stop_point =
|
141
|
-
subject =
|
143
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
144
|
+
subject = create :access_point, :stop_area => commercial_stop_point
|
142
145
|
subject.generic_access_link_matrix.each do |link|
|
143
|
-
link.id.
|
146
|
+
expect(link.id).to be_nil
|
144
147
|
end
|
145
148
|
end
|
146
149
|
it "should have only last generic_access_links as new in matrix" do
|
147
|
-
commercial_stop_point =
|
148
|
-
subject =
|
149
|
-
link =
|
150
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
151
|
+
subject = create :access_point, :stop_area => commercial_stop_point
|
152
|
+
link = create :access_link, :access_point => subject, :stop_area => commercial_stop_point
|
150
153
|
subject.generic_access_link_matrix.each do |link|
|
151
154
|
if link.link_key.start_with?"A_"
|
152
|
-
link.id.
|
155
|
+
expect(link.id).not_to be_nil
|
153
156
|
else
|
154
|
-
link.id.
|
157
|
+
expect(link.id).to be_nil
|
155
158
|
end
|
156
159
|
end
|
157
160
|
end
|
@@ -159,32 +162,32 @@ describe Chouette::AccessPoint do
|
|
159
162
|
|
160
163
|
describe "#detail_access_link_matrix" do
|
161
164
|
it "should have 4 detail_access_links in matrix" do
|
162
|
-
stop_place =
|
163
|
-
commercial_stop_point =
|
164
|
-
quay1 =
|
165
|
-
quay2 =
|
166
|
-
subject =
|
167
|
-
subject.detail_access_link_matrix.size.
|
165
|
+
stop_place = create :stop_area, :area_type => "StopPlace"
|
166
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
|
167
|
+
quay1 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
168
|
+
quay2 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
169
|
+
subject = create :access_point, :stop_area => stop_place
|
170
|
+
expect(subject.detail_access_link_matrix.size).to eq(4)
|
168
171
|
end
|
169
172
|
|
170
173
|
it "should have new detail_access_links in matrix" do
|
171
|
-
commercial_stop_point =
|
172
|
-
quay =
|
173
|
-
subject =
|
174
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
175
|
+
quay = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
176
|
+
subject = create :access_point, :stop_area => commercial_stop_point
|
174
177
|
subject.detail_access_link_matrix.each do |link|
|
175
|
-
link.id.
|
178
|
+
expect(link.id).to be_nil
|
176
179
|
end
|
177
180
|
end
|
178
181
|
it "should have only last detail_access_links as new in matrix" do
|
179
|
-
commercial_stop_point =
|
180
|
-
quay =
|
181
|
-
subject =
|
182
|
-
link =
|
182
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
183
|
+
quay = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
|
184
|
+
subject = create :access_point, :stop_area => commercial_stop_point
|
185
|
+
link = create :access_link, :access_point => subject, :stop_area => quay
|
183
186
|
subject.detail_access_link_matrix.each do |link|
|
184
187
|
if link.link_key.start_with?"A_"
|
185
|
-
link.id.
|
188
|
+
expect(link.id).not_to be_nil
|
186
189
|
else
|
187
|
-
link.id.
|
190
|
+
expect(link.id).to be_nil
|
188
191
|
end
|
189
192
|
end
|
190
193
|
end
|
@@ -192,74 +195,74 @@ describe Chouette::AccessPoint do
|
|
192
195
|
|
193
196
|
describe "#coordinates" do
|
194
197
|
it "should convert coordinates into latitude/longitude" do
|
195
|
-
commercial_stop_point =
|
196
|
-
subject =
|
197
|
-
subject.longitude.
|
198
|
-
subject.latitude.
|
198
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
199
|
+
subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "45.123,120.456"
|
200
|
+
expect(subject.longitude).to be_within(0.001).of(120.456)
|
201
|
+
expect(subject.latitude).to be_within(0.001).of(45.123)
|
199
202
|
end
|
200
203
|
it "should set empty coordinates into nil latitude/longitude" do
|
201
|
-
commercial_stop_point =
|
202
|
-
subject =
|
203
|
-
subject.longitude.
|
204
|
-
subject.latitude.
|
204
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
205
|
+
subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "45.123,120.456"
|
206
|
+
expect(subject.longitude).to be_within(0.001).of(120.456)
|
207
|
+
expect(subject.latitude).to be_within(0.001).of(45.123)
|
205
208
|
subject.coordinates = ""
|
206
209
|
subject.save
|
207
|
-
subject.longitude.
|
208
|
-
subject.latitude.
|
210
|
+
expect(subject.longitude).to be_nil
|
211
|
+
expect(subject.latitude).to be_nil
|
209
212
|
end
|
210
213
|
it "should convert latitude/longitude into coordinates" do
|
211
|
-
commercial_stop_point =
|
212
|
-
subject =
|
213
|
-
subject.coordinates.
|
214
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
215
|
+
subject = create :access_point, :stop_area => commercial_stop_point, :longitude => 120.456, :latitude => 45.123
|
216
|
+
expect(subject.coordinates).to eq("45.123,120.456")
|
214
217
|
end
|
215
218
|
it "should convert nil latitude/longitude into empty coordinates" do
|
216
|
-
commercial_stop_point =
|
217
|
-
subject =
|
218
|
-
subject.coordinates.
|
219
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
220
|
+
subject = create :access_point, :stop_area => commercial_stop_point, :longitude => nil, :latitude => nil
|
221
|
+
expect(subject.coordinates).to eq("")
|
219
222
|
end
|
220
223
|
it "should accept valid coordinates" do
|
221
|
-
commercial_stop_point =
|
222
|
-
subject =
|
223
|
-
subject.valid
|
224
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
225
|
+
subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "45.123,120.456"
|
226
|
+
expect(subject.valid?).to be_truthy
|
224
227
|
subject.coordinates = "45.123, 120.456"
|
225
|
-
subject.valid
|
226
|
-
subject.longitude.
|
227
|
-
subject.latitude.
|
228
|
+
expect(subject.valid?).to be_truthy
|
229
|
+
expect(subject.longitude).to be_within(0.001).of(120.456)
|
230
|
+
expect(subject.latitude).to be_within(0.001).of(45.123)
|
228
231
|
subject.coordinates = "45.123, -120.456"
|
229
|
-
subject.valid
|
232
|
+
expect(subject.valid?).to be_truthy
|
230
233
|
subject.coordinates = "45.123 ,120.456"
|
231
|
-
subject.valid
|
234
|
+
expect(subject.valid?).to be_truthy
|
232
235
|
subject.coordinates = "45.123 , 120.456"
|
233
|
-
subject.valid
|
236
|
+
expect(subject.valid?).to be_truthy
|
234
237
|
subject.coordinates = " 45.123,120.456"
|
235
|
-
subject.valid
|
238
|
+
expect(subject.valid?).to be_truthy
|
236
239
|
subject.coordinates = "45.123,120.456 "
|
237
|
-
subject.valid
|
240
|
+
expect(subject.valid?).to be_truthy
|
238
241
|
end
|
239
242
|
it "should accept valid coordinates on limits" do
|
240
|
-
commercial_stop_point =
|
241
|
-
subject =
|
242
|
-
subject.valid
|
243
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
244
|
+
subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "90,180"
|
245
|
+
expect(subject.valid?).to be_truthy
|
243
246
|
subject.coordinates = "-90,-180"
|
244
|
-
subject.valid
|
247
|
+
expect(subject.valid?).to be_truthy
|
245
248
|
subject.coordinates = "-90.,180."
|
246
|
-
subject.valid
|
249
|
+
expect(subject.valid?).to be_truthy
|
247
250
|
subject.coordinates = "-90.0,180.00"
|
248
|
-
subject.valid
|
251
|
+
expect(subject.valid?).to be_truthy
|
249
252
|
end
|
250
253
|
it "should reject invalid coordinates" do
|
251
|
-
commercial_stop_point =
|
252
|
-
subject =
|
254
|
+
commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
|
255
|
+
subject = create :access_point, :stop_area => commercial_stop_point
|
253
256
|
subject.coordinates = ",12"
|
254
|
-
subject.valid
|
257
|
+
expect(subject.valid?).to be_falsey
|
255
258
|
subject.coordinates = "-90"
|
256
|
-
subject.valid
|
259
|
+
expect(subject.valid?).to be_falsey
|
257
260
|
subject.coordinates = "-90.1,180."
|
258
|
-
subject.valid
|
261
|
+
expect(subject.valid?).to be_falsey
|
259
262
|
subject.coordinates = "-90.0,180.1"
|
260
|
-
subject.valid
|
263
|
+
expect(subject.valid?).to be_falsey
|
261
264
|
subject.coordinates = "-91.0,18.1"
|
262
|
-
subject.valid
|
265
|
+
expect(subject.valid?).to be_falsey
|
263
266
|
end
|
264
267
|
end
|
265
268
|
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::ActiveRecord do
|
3
|
+
describe Chouette::ActiveRecord, :type => :model do
|
4
4
|
|
5
|
-
it { Chouette::ActiveRecord.ancestors.
|
5
|
+
it { expect(Chouette::ActiveRecord.ancestors).to include(ActiveRecord::Base) }
|
6
6
|
|
7
7
|
describe "table_name" do
|
8
8
|
|
9
9
|
it "should return line for Chouette::Line" do
|
10
|
-
Chouette::Line.table_name.
|
10
|
+
expect(Chouette::Line.table_name).to eq("lines")
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should return ptnetwork for Chouette::Network" do
|
14
|
-
Chouette::Network.table_name.
|
14
|
+
expect(Chouette::Network.table_name).to eq("networks")
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return timetable_date for Chouette::TimeTableDate" do
|
18
|
-
Chouette::TimeTableDate.table_name.
|
18
|
+
expect(Chouette::TimeTableDate.table_name).to eq("time_table_dates")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return timetable_period for Chouette::TimeTablePeriod" do
|
22
|
-
Chouette::TimeTablePeriod.table_name.
|
22
|
+
expect(Chouette::TimeTablePeriod.table_name).to eq("time_table_periods")
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -28,7 +28,7 @@ describe Chouette::ActiveRecord do
|
|
28
28
|
|
29
29
|
it "should support method with additionnal underscores" do
|
30
30
|
stop_area = Chouette::StopArea.new
|
31
|
-
stop_area.area_type.
|
31
|
+
expect(stop_area.area_type).to eq(stop_area.area_type)
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -38,84 +38,84 @@ describe Chouette::ActiveRecord do
|
|
38
38
|
|
39
39
|
it "should respond to method with additionnal underscores" do
|
40
40
|
stop_area = Chouette::StopArea.new
|
41
|
-
stop_area.respond_to?(:area_type).
|
41
|
+
expect(stop_area.respond_to?(:area_type)).to be_truthy
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
# describe "create_reflection" do
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
# let(:macro) { :has_many }
|
49
|
+
# let(:name) { :lines }
|
50
|
+
# let(:options) { {} }
|
51
|
+
# let(:active_record) { Chouette::Network }
|
52
52
|
|
53
|
-
|
53
|
+
# let(:modified_options) { {:modified => true} }
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
# it "should invoke create_reflection_without_chouette_naming with modified options" do
|
56
|
+
# allow(Chouette::ActiveRecord::Reflection).to receive_messages :new => double(:options_with_default => modified_options)
|
57
|
+
# expect(Chouette::ActiveRecord).to receive(:create_reflection_without_chouette_naming).with macro, name, modified_options, active_record
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
# Chouette::ActiveRecord.create_reflection macro, name, options, active_record
|
60
|
+
# end
|
61
61
|
|
62
|
-
|
62
|
+
# end
|
63
63
|
|
64
64
|
end
|
65
65
|
|
66
|
-
describe Chouette::ActiveRecord::Reflection do
|
66
|
+
# describe Chouette::ActiveRecord::Reflection, :type => :model do
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
# let(:macro) { :has_many }
|
69
|
+
# let(:name) { :lines }
|
70
|
+
# let(:options) { {} }
|
71
|
+
# let(:active_record) { Chouette::Network }
|
72
72
|
|
73
|
-
|
73
|
+
# subject { Chouette::ActiveRecord::Reflection.new macro, name, options, active_record }
|
74
74
|
|
75
|
-
|
75
|
+
# describe "collection?" do
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
# it "should be true when macro is has_many" do
|
78
|
+
# allow(subject).to receive_messages :macro => :has_many
|
79
|
+
# expect(subject).to be_collection
|
80
|
+
# end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
# it "should be false when macro is belongs_to" do
|
83
|
+
# allow(subject).to receive_messages :macro => :belong_to
|
84
|
+
# expect(subject).not_to be_collection
|
85
|
+
# end
|
86
86
|
|
87
|
-
|
87
|
+
# end
|
88
88
|
|
89
|
-
|
89
|
+
# describe "class_name" do
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
# it "should be Chouette::Line when name is line" do
|
92
|
+
# allow(subject).to receive_messages :name => "line"
|
93
|
+
# expect(subject.class_name).to eq("Chouette::Line")
|
94
|
+
# end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
# it "should be Chouette::Routes when name is routes and reflection is a collection" do
|
97
|
+
# allow(subject).to receive_messages :name => "routes", :collection? => true
|
98
|
+
# expect(subject.class_name).to eq("Chouette::Route")
|
99
|
+
# end
|
100
100
|
|
101
|
-
|
101
|
+
# end
|
102
102
|
|
103
103
|
|
104
|
-
|
104
|
+
# describe "options" do
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
# it "should define class_name if not" do
|
107
|
+
# allow(subject).to receive_messages :options => {}, :class_name => "class_name"
|
108
|
+
# expect(subject.options_with_default[:class_name]).to eq("class_name")
|
109
|
+
# end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
# it "should not define class_name if presents" do
|
112
|
+
# allow(subject).to receive_messages :options => {:class_name => "dummy"}
|
113
|
+
# expect(subject.options_with_default[:class_name]).to eq("dummy")
|
114
|
+
# end
|
115
115
|
|
116
|
-
|
116
|
+
# end
|
117
117
|
|
118
118
|
|
119
|
-
end
|
119
|
+
# end
|
120
120
|
|
121
121
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::AreaType do
|
3
|
+
describe Chouette::AreaType, :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::AreaType 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("boarding_position").to_i.
|
29
|
+
expect(mode("boarding_position").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 eq("boarding_position")
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should accept another mode" do
|
37
|
-
Chouette::AreaType.new(mode("test")).
|
37
|
+
expect(Chouette::AreaType.new(mode("test"))).to eq(mode("test"))
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -44,7 +44,7 @@ describe Chouette::AreaType do
|
|
44
44
|
|
45
45
|
Chouette::AreaType.definitions.each do |text_code, numerical_code|
|
46
46
|
it "should include a AreaType #{text_code}" do
|
47
|
-
Chouette::AreaType.all.
|
47
|
+
expect(Chouette::AreaType.all).to include(Chouette::AreaType.new(text_code))
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chouette::Company do
|
3
|
+
describe Chouette::Company, :type => :model do
|
4
4
|
|
5
|
-
subject {
|
5
|
+
subject { create(:company) }
|
6
6
|
|
7
|
-
it {
|
8
|
-
it {
|
7
|
+
it { is_expected.to validate_presence_of :registration_number }
|
8
|
+
it { is_expected.to validate_uniqueness_of :registration_number }
|
9
9
|
|
10
|
-
it {
|
10
|
+
it { is_expected.to validate_presence_of :name }
|
11
11
|
|
12
12
|
# it { should validate_presence_of :objectid }
|
13
|
-
it {
|
13
|
+
it { is_expected.to validate_uniqueness_of :objectid }
|
14
14
|
|
15
15
|
describe "#nullables empty" do
|
16
16
|
it "should set null empty nullable attributes" do
|
@@ -21,12 +21,12 @@ describe Chouette::Company do
|
|
21
21
|
subject.fax = ''
|
22
22
|
subject.email = ''
|
23
23
|
subject.nil_if_blank
|
24
|
-
subject.organizational_unit.
|
25
|
-
subject.operating_department_name.
|
26
|
-
subject.code.
|
27
|
-
subject.phone.
|
28
|
-
subject.fax.
|
29
|
-
subject.email.
|
24
|
+
expect(subject.organizational_unit).to be_nil
|
25
|
+
expect(subject.operating_department_name).to be_nil
|
26
|
+
expect(subject.code).to be_nil
|
27
|
+
expect(subject.phone).to be_nil
|
28
|
+
expect(subject.fax).to be_nil
|
29
|
+
expect(subject.email).to be_nil
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -39,12 +39,12 @@ describe Chouette::Company do
|
|
39
39
|
subject.fax = 'z'
|
40
40
|
subject.email = 'r'
|
41
41
|
subject.nil_if_blank
|
42
|
-
subject.organizational_unit.
|
43
|
-
subject.operating_department_name.
|
44
|
-
subject.code.
|
45
|
-
subject.phone.
|
46
|
-
subject.fax.
|
47
|
-
subject.email.
|
42
|
+
expect(subject.organizational_unit).not_to be_nil
|
43
|
+
expect(subject.operating_department_name).not_to be_nil
|
44
|
+
expect(subject.code).not_to be_nil
|
45
|
+
expect(subject.phone).not_to be_nil
|
46
|
+
expect(subject.fax).not_to be_nil
|
47
|
+
expect(subject.email).not_to be_nil
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|