ninoxe 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +13 -5
  2. data/app/models/chouette/company.rb +3 -4
  3. data/app/models/chouette/line.rb +0 -1
  4. data/app/models/chouette/network.rb +4 -5
  5. data/app/models/chouette/stop_area.rb +25 -26
  6. data/config/database.yml.me +11 -0
  7. data/db/migrate/20150630135517_remove_uniqueness_for_registration_number.rb +22 -0
  8. data/lib/ninoxe.rb~ +7 -0
  9. data/lib/ninoxe/version.rb +1 -1
  10. metadata +45 -212
  11. data/spec/dummy/README.rdoc +0 -28
  12. data/spec/dummy/Rakefile +0 -6
  13. data/spec/dummy/app/assets/images/.keep +0 -0
  14. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  15. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  16. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  17. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  18. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  19. data/spec/dummy/app/mailers/.keep +0 -0
  20. data/spec/dummy/app/models/.keep +0 -0
  21. data/spec/dummy/app/models/concerns/.keep +0 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  23. data/spec/dummy/bin/bundle +0 -3
  24. data/spec/dummy/bin/rails +0 -4
  25. data/spec/dummy/bin/rake +0 -4
  26. data/spec/dummy/config.ru +0 -4
  27. data/spec/dummy/config/application.rb +0 -28
  28. data/spec/dummy/config/boot.rb +0 -5
  29. data/spec/dummy/config/database.yml +0 -19
  30. data/spec/dummy/config/environment.rb +0 -5
  31. data/spec/dummy/config/environments/development.rb +0 -29
  32. data/spec/dummy/config/environments/production.rb +0 -80
  33. data/spec/dummy/config/environments/test.rb +0 -36
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  35. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  36. data/spec/dummy/config/initializers/inflections.rb +0 -16
  37. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  38. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  39. data/spec/dummy/config/initializers/session_store.rb +0 -3
  40. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  41. data/spec/dummy/config/locales/en.yml +0 -23
  42. data/spec/dummy/config/locales/fr.yml +0 -23
  43. data/spec/dummy/config/routes.rb +0 -4
  44. data/spec/dummy/db/schema.rb +0 -489
  45. data/spec/dummy/db/test.sqlite3 +0 -0
  46. data/spec/dummy/lib/assets/.keep +0 -0
  47. data/spec/dummy/log/.keep +0 -0
  48. data/spec/dummy/public/404.html +0 -58
  49. data/spec/dummy/public/422.html +0 -58
  50. data/spec/dummy/public/500.html +0 -57
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/script/rails +0 -6
  53. data/spec/factories/chouette_access_links.rb +0 -13
  54. data/spec/factories/chouette_access_points.rb +0 -12
  55. data/spec/factories/chouette_companies.rb +0 -9
  56. data/spec/factories/chouette_connection_links.rb +0 -13
  57. data/spec/factories/chouette_footnotes.rb +0 -10
  58. data/spec/factories/chouette_group_of_lines.rb +0 -9
  59. data/spec/factories/chouette_journey_pattern.rb +0 -40
  60. data/spec/factories/chouette_lines.rb +0 -44
  61. data/spec/factories/chouette_networks.rb +0 -9
  62. data/spec/factories/chouette_routes.rb +0 -26
  63. data/spec/factories/chouette_stop_areas.rb +0 -12
  64. data/spec/factories/chouette_stop_points.rb +0 -10
  65. data/spec/factories/chouette_time_table.rb +0 -37
  66. data/spec/factories/chouette_vehicle_journey.rb +0 -66
  67. data/spec/factories/chouette_vehicle_journey_at_stop.rb +0 -8
  68. data/spec/models/chouette/access_link_spec.rb +0 -82
  69. data/spec/models/chouette/access_point_spec.rb +0 -269
  70. data/spec/models/chouette/active_record_spec.rb +0 -121
  71. data/spec/models/chouette/area_type_spec.rb +0 -53
  72. data/spec/models/chouette/company_spec.rb +0 -51
  73. data/spec/models/chouette/connection_link_spec.rb +0 -60
  74. data/spec/models/chouette/direction_spec.rb +0 -60
  75. data/spec/models/chouette/exporter_spec.rb +0 -28
  76. data/spec/models/chouette/file_validator_spec.rb +0 -28
  77. data/spec/models/chouette/footnote_spec.rb +0 -9
  78. data/spec/models/chouette/group_of_line_spec.rb +0 -31
  79. data/spec/models/chouette/journey_pattern_spec.rb +0 -64
  80. data/spec/models/chouette/line_spec.rb +0 -123
  81. data/spec/models/chouette/loader_spec.rb +0 -69
  82. data/spec/models/chouette/network_spec.rb +0 -22
  83. data/spec/models/chouette/object_id_spec.rb +0 -149
  84. data/spec/models/chouette/route_spec.rb +0 -238
  85. data/spec/models/chouette/stop_area_spec.rb +0 -443
  86. data/spec/models/chouette/stop_point_spec.rb +0 -41
  87. data/spec/models/chouette/time_table_period_spec.rb +0 -66
  88. data/spec/models/chouette/time_table_spec.rb +0 -1266
  89. data/spec/models/chouette/transport_mode_spec.rb +0 -64
  90. data/spec/models/chouette/trident_active_record_spec.rb +0 -115
  91. data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +0 -47
  92. data/spec/models/chouette/vehicle_journey_spec.rb +0 -223
  93. data/spec/presenters/chouette/geometry/general_presenter.rb +0 -1
  94. data/spec/presenters/chouette/geometry/line_presenter_spec.rb +0 -13
  95. data/spec/spec_helper.rb +0 -58
@@ -1,66 +0,0 @@
1
- FactoryGirl.define do
2
-
3
- factory :vehicle_journey_common, :class => Chouette::VehicleJourney do
4
- sequence(:objectid) { |n| "test:VehicleJourney:#{n}" }
5
-
6
- factory :vehicle_journey do
7
- association :journey_pattern, :factory => :journey_pattern
8
-
9
- after(:build) do |vehicle_journey|
10
- vehicle_journey.route = vehicle_journey.journey_pattern.route
11
- end
12
-
13
- after(:create) do |vehicle_journey|
14
- vehicle_journey.journey_pattern.stop_points.each_with_index do |stop_point, index|
15
- vehicle_journey.vehicle_journey_at_stops << create(:vehicle_journey_at_stop,
16
- :vehicle_journey => vehicle_journey,
17
- :stop_point => stop_point,
18
- :arrival_time => (-1 * index).minutes.ago,
19
- :departure_time => (-1 * index).minutes.ago)
20
- end
21
- end
22
-
23
- factory :vehicle_journey_odd do
24
- association :journey_pattern, :factory => :journey_pattern_odd
25
- end
26
-
27
- factory :vehicle_journey_even do
28
- association :journey_pattern, :factory => :journey_pattern_even
29
- end
30
- end
31
- end
32
- end
33
-
34
- # after(:build) do |vehicle_journey|
35
- # vehicle_journey.route_id = vehicle_journey.journey_pattern.route_id
36
- # end
37
- #
38
- # after(:create) do |vehicle_journey|
39
- # vehicle_journey.journey_pattern.stop_points.each_with_index do |stop_point, index|
40
- # vehicle_journey.vehicle_journey_at_stops.create(:vehicle_journey_at_stop,
41
- # :vehicle_journey => vehicle_journey,
42
- # :stop_point => stop_point,
43
- # :arrival_time => (-1 * index).minutes.ago,
44
- # :departure_time => (-1 * index).minutes.ago)
45
- # end
46
- # end
47
- # end
48
- #
49
- # after(:build) do |vehicle_journey|
50
- # vehicle_journey.route_id = vehicle_journey.journey_pattern.route_id
51
- # end
52
- #
53
- # after(:create) do |vehicle_journey|
54
- # vehicle_journey.journey_pattern.stop_points.each_with_index do |stop_point, index|
55
- # vehicle_journey.vehicle_journey_at_stops.create(:vehicle_journey_at_stop,
56
- # :vehicle_journey => vehicle_journey,
57
- # :stop_point => stop_point,
58
- # :arrival_time => (-1 * index).minutes.ago,
59
- # :departure_time => (-1 * index).minutes.ago)
60
- # end
61
- # end
62
- # end
63
- #
64
- # end
65
- #end
66
- #
@@ -1,8 +0,0 @@
1
- FactoryGirl.define do
2
-
3
- factory :vehicle_journey_at_stop, :class => Chouette::VehicleJourneyAtStop do
4
- association :vehicle_journey, :factory => :vehicle_journey
5
- end
6
-
7
- end
8
-
@@ -1,82 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::AccessLink, :type => :model do
4
- subject { create(:access_link) }
5
-
6
- it { is_expected.to validate_uniqueness_of :objectid }
7
-
8
- describe '#objectid' do
9
- subject { super().objectid }
10
- it { is_expected.to be_kind_of(Chouette::ObjectId) }
11
- end
12
-
13
- it { is_expected.to validate_presence_of :name }
14
- it { is_expected.to validate_presence_of :link_type }
15
- it { is_expected.to validate_presence_of :link_orientation }
16
-
17
- describe "#access_link_type" do
18
-
19
- def self.legacy_link_types
20
- %w{Underground Mixed Overground}
21
- end
22
-
23
- legacy_link_types.each do |link_type|
24
- context "when link_type is #{link_type}" do
25
- access_link_type = Chouette::ConnectionLinkType.new(link_type.underscore)
26
- it "should be #{access_link_type}" do
27
- subject.link_type = link_type
28
- expect(subject.access_link_type).to eq(access_link_type)
29
- end
30
- end
31
- end
32
- end
33
-
34
- describe "#access_link_type=" do
35
-
36
- it "should change link_type with ConnectionLinkType#name" do
37
- subject.access_link_type = "underground"
38
- expect(subject.link_type).to eq("Underground")
39
- end
40
-
41
- end
42
-
43
- describe "#link_orientation_type" do
44
-
45
- def self.legacy_link_orientations
46
- %w{AccessPointToStopArea StopAreaToAccessPoint}
47
- end
48
-
49
- legacy_link_orientations.each do |link_orientation|
50
- context "when link_orientation is #{link_orientation}" do
51
- link_orientation_type = Chouette::LinkOrientationType.new(link_orientation.underscore)
52
- it "should be #{link_orientation_type}" do
53
- subject.link_orientation = link_orientation
54
- expect(subject.link_orientation_type).to eq(link_orientation_type)
55
- end
56
- end
57
- end
58
-
59
- end
60
-
61
- describe "#link_orientation_type=" do
62
-
63
- it "should change link_orientation with LinkOrientationType#name" do
64
- subject.link_orientation_type = "access_point_to_stop_area"
65
- expect(subject.link_orientation).to eq("AccessPointToStopArea")
66
- end
67
-
68
- end
69
-
70
- describe "#link_key" do
71
- it "should calculate link_key for access to area" do
72
- subject.link_orientation_type = "access_point_to_stop_area"
73
- expect(subject.link_key).to eq("A_#{subject.access_point.id}-S_#{subject.stop_area.id}")
74
- end
75
- it "should calculate link_key for area to access" do
76
- subject.link_orientation_type = "stop_area_to_access_point"
77
- expect(subject.link_key).to eq("S_#{subject.stop_area.id}-A_#{subject.access_point.id}")
78
- end
79
-
80
- end
81
-
82
- end
@@ -1,269 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::AccessPoint, :type => :model do
4
-
5
- describe '#objectid' do
6
- subject { super().objectid }
7
- it { is_expected.to be_kind_of(Chouette::ObjectId) }
8
- end
9
-
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 }
13
-
14
- describe ".latitude" do
15
- it "should accept -90 value" do
16
- subject = create :access_point
17
- subject.latitude = -90
18
- expect(subject.valid?).to be_truthy
19
- end
20
- it "should reject < -90 value" do
21
- subject = create :access_point
22
- subject.latitude = -90.0001
23
- expect(subject.valid?).to be_falsey
24
- end
25
- it "should accept 90 value" do
26
- subject = create :access_point
27
- subject.latitude = 90
28
- expect(subject.valid?).to be_truthy
29
- end
30
- it "should reject > 90 value" do
31
- subject = create :access_point
32
- subject.latitude = 90.0001
33
- expect(subject.valid?).to be_falsey
34
- end
35
- end
36
-
37
- describe ".longitude" do
38
- it "should accept -180 value" do
39
- subject = create :access_point
40
- subject.longitude = -180
41
- expect(subject.valid?).to be_truthy
42
- end
43
- it "should reject < -180 value" do
44
- subject = create :access_point
45
- subject.longitude = -180.0001
46
- expect(subject.valid?).to be_falsey
47
- end
48
- it "should accept 180 value" do
49
- subject = create :access_point
50
- subject.longitude = 180
51
- expect(subject.valid?).to be_truthy
52
- end
53
- it "should reject > 180 value" do
54
- subject = create :access_point
55
- subject.longitude = 180.0001
56
- expect(subject.valid?).to be_falsey
57
- end
58
- end
59
-
60
- describe ".long_lat" do
61
- it "should accept longitude and latitude both as nil" do
62
- subject = create :access_point
63
- subject.longitude = nil
64
- subject.latitude = nil
65
- expect(subject.valid?).to be_truthy
66
- end
67
- it "should accept longitude and latitude both numerical" do
68
- subject = create :access_point
69
- subject.longitude = 10
70
- subject.latitude = 10
71
- expect(subject.valid?).to be_truthy
72
- end
73
- it "should reject longitude nil with latitude numerical" do
74
- subject = create :access_point
75
- subject.longitude = nil
76
- subject.latitude = 10
77
- expect(subject.valid?).to be_falsey
78
- end
79
- it "should reject longitude numerical with latitude nil" do
80
- subject = create :access_point
81
- subject.longitude = 10
82
- subject.latitude = nil
83
- expect(subject.valid?).to be_falsey
84
- end
85
- end
86
-
87
- describe "#access_type" do
88
- def self.legacy_access_types
89
- %w{In Out InOut}
90
- end
91
-
92
- legacy_access_types.each do |access_type|
93
- context "when access_type is #{access_type}" do
94
- access_point_type = Chouette::AccessPointType.new(access_type.underscore)
95
- it "should be #{access_point_type}" do
96
- subject.access_type = access_type
97
- expect(subject.access_point_type).to eq(access_point_type)
98
- end
99
- end
100
- end
101
- end
102
-
103
- describe "#access_point_type=" do
104
- it "should change access_type with Chouette::AccessPointType#name" do
105
- subject.access_point_type = "in_out"
106
- expect(subject.access_type).to eq("InOut")
107
- end
108
-
109
- end
110
-
111
- describe "#to_lat_lng" do
112
-
113
- it "should return nil if latitude is nil" do
114
- subject.latitude = nil
115
- expect(subject.to_lat_lng).to be_nil
116
- end
117
-
118
- it "should return nil if longitude is nil" do
119
- subject.longitude = nil
120
- expect(subject.to_lat_lng).to be_nil
121
- end
122
-
123
- end
124
-
125
- describe "#geometry" do
126
-
127
- it "should be nil when to_lat_lng is nil" do
128
- allow(subject).to receive_messages :to_lat_lng => nil
129
- expect(subject.geometry).to be_nil
130
- end
131
-
132
- end
133
-
134
- describe "#generic_access_link_matrix" do
135
- it "should have 2 generic_access_links in matrix" do
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)
140
- end
141
-
142
- it "should have new generic_access_links in matrix" do
143
- commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
144
- subject = create :access_point, :stop_area => commercial_stop_point
145
- subject.generic_access_link_matrix.each do |link|
146
- expect(link.id).to be_nil
147
- end
148
- end
149
- it "should have only last generic_access_links as new in matrix" do
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
153
- subject.generic_access_link_matrix.each do |link|
154
- if link.link_key.start_with?"A_"
155
- expect(link.id).not_to be_nil
156
- else
157
- expect(link.id).to be_nil
158
- end
159
- end
160
- end
161
- end
162
-
163
- describe "#detail_access_link_matrix" do
164
- it "should have 4 detail_access_links in matrix" do
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)
171
- end
172
-
173
- it "should have new detail_access_links in matrix" do
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
177
- subject.detail_access_link_matrix.each do |link|
178
- expect(link.id).to be_nil
179
- end
180
- end
181
- it "should have only last detail_access_links as new in matrix" do
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
186
- subject.detail_access_link_matrix.each do |link|
187
- if link.link_key.start_with?"A_"
188
- expect(link.id).not_to be_nil
189
- else
190
- expect(link.id).to be_nil
191
- end
192
- end
193
- end
194
- end
195
-
196
- describe "#coordinates" do
197
- it "should convert coordinates into latitude/longitude" do
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)
202
- end
203
- it "should set empty coordinates into nil latitude/longitude" do
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)
208
- subject.coordinates = ""
209
- subject.save
210
- expect(subject.longitude).to be_nil
211
- expect(subject.latitude).to be_nil
212
- end
213
- it "should convert latitude/longitude into coordinates" do
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")
217
- end
218
- it "should convert nil latitude/longitude into empty coordinates" do
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("")
222
- end
223
- it "should accept valid coordinates" do
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
227
- subject.coordinates = "45.123, 120.456"
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)
231
- subject.coordinates = "45.123, -120.456"
232
- expect(subject.valid?).to be_truthy
233
- subject.coordinates = "45.123 ,120.456"
234
- expect(subject.valid?).to be_truthy
235
- subject.coordinates = "45.123 , 120.456"
236
- expect(subject.valid?).to be_truthy
237
- subject.coordinates = " 45.123,120.456"
238
- expect(subject.valid?).to be_truthy
239
- subject.coordinates = "45.123,120.456 "
240
- expect(subject.valid?).to be_truthy
241
- end
242
- it "should accept valid coordinates on limits" do
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
246
- subject.coordinates = "-90,-180"
247
- expect(subject.valid?).to be_truthy
248
- subject.coordinates = "-90.,180."
249
- expect(subject.valid?).to be_truthy
250
- subject.coordinates = "-90.0,180.00"
251
- expect(subject.valid?).to be_truthy
252
- end
253
- it "should reject invalid coordinates" do
254
- commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
255
- subject = create :access_point, :stop_area => commercial_stop_point
256
- subject.coordinates = ",12"
257
- expect(subject.valid?).to be_falsey
258
- subject.coordinates = "-90"
259
- expect(subject.valid?).to be_falsey
260
- subject.coordinates = "-90.1,180."
261
- expect(subject.valid?).to be_falsey
262
- subject.coordinates = "-90.0,180.1"
263
- expect(subject.valid?).to be_falsey
264
- subject.coordinates = "-91.0,18.1"
265
- expect(subject.valid?).to be_falsey
266
- end
267
- end
268
-
269
- end
@@ -1,121 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::ActiveRecord, :type => :model do
4
-
5
- it { expect(Chouette::ActiveRecord.ancestors).to include(ActiveRecord::Base) }
6
-
7
- describe "table_name" do
8
-
9
- it "should return line for Chouette::Line" do
10
- expect(Chouette::Line.table_name).to eq("lines")
11
- end
12
-
13
- it "should return ptnetwork for Chouette::Network" do
14
- expect(Chouette::Network.table_name).to eq("networks")
15
- end
16
-
17
- it "should return timetable_date for Chouette::TimeTableDate" do
18
- expect(Chouette::TimeTableDate.table_name).to eq("time_table_dates")
19
- end
20
-
21
- it "should return timetable_period for Chouette::TimeTablePeriod" do
22
- expect(Chouette::TimeTablePeriod.table_name).to eq("time_table_periods")
23
- end
24
-
25
- end
26
-
27
- describe "method_missing" do
28
-
29
- it "should support method with additionnal underscores" do
30
- stop_area = Chouette::StopArea.new
31
- expect(stop_area.area_type).to eq(stop_area.area_type)
32
- end
33
-
34
- end
35
-
36
-
37
- describe "respond_to?" do
38
-
39
- it "should respond to method with additionnal underscores" do
40
- stop_area = Chouette::StopArea.new
41
- expect(stop_area.respond_to?(:area_type)).to be_truthy
42
- end
43
-
44
- end
45
-
46
- # describe "create_reflection" do
47
-
48
- # let(:macro) { :has_many }
49
- # let(:name) { :lines }
50
- # let(:options) { {} }
51
- # let(:active_record) { Chouette::Network }
52
-
53
- # let(:modified_options) { {:modified => true} }
54
-
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
-
59
- # Chouette::ActiveRecord.create_reflection macro, name, options, active_record
60
- # end
61
-
62
- # end
63
-
64
- end
65
-
66
- # describe Chouette::ActiveRecord::Reflection, :type => :model do
67
-
68
- # let(:macro) { :has_many }
69
- # let(:name) { :lines }
70
- # let(:options) { {} }
71
- # let(:active_record) { Chouette::Network }
72
-
73
- # subject { Chouette::ActiveRecord::Reflection.new macro, name, options, active_record }
74
-
75
- # describe "collection?" do
76
-
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
-
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
-
87
- # end
88
-
89
- # describe "class_name" do
90
-
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
-
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
-
101
- # end
102
-
103
-
104
- # describe "options" do
105
-
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
-
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
-
116
- # end
117
-
118
-
119
- # end
120
-
121
-