ninoxe 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/lib/ninoxe/version.rb +1 -1
  3. data/spec/dummy/README.rdoc +261 -0
  4. data/spec/dummy/Rakefile +6 -0
  5. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  6. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  7. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  8. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  9. data/spec/dummy/app/mailers/.gitkeep +0 -0
  10. data/spec/dummy/app/models/.gitkeep +0 -0
  11. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  12. data/spec/dummy/config/application.rb +56 -0
  13. data/spec/dummy/config/boot.rb +10 -0
  14. data/spec/dummy/config/database.yml +9 -0
  15. data/spec/dummy/config/environment.rb +7 -0
  16. data/spec/dummy/config/environments/development.rb +37 -0
  17. data/spec/dummy/config/environments/production.rb +67 -0
  18. data/spec/dummy/config/environments/test.rb +37 -0
  19. data/spec/dummy/config/initializers/active_record.rb +2 -0
  20. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  21. data/spec/dummy/config/initializers/inflections.rb +15 -0
  22. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  23. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  24. data/spec/dummy/config/initializers/session_store.rb +8 -0
  25. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  26. data/spec/dummy/config/locales/en.yml +5 -0
  27. data/spec/dummy/config/routes.rb +4 -0
  28. data/spec/dummy/config.ru +4 -0
  29. data/spec/dummy/db/test.sqlite3 +0 -0
  30. data/spec/dummy/lib/assets/.gitkeep +0 -0
  31. data/spec/dummy/log/.gitkeep +0 -0
  32. data/spec/dummy/public/404.html +26 -0
  33. data/spec/dummy/public/422.html +26 -0
  34. data/spec/dummy/public/500.html +25 -0
  35. data/spec/dummy/public/favicon.ico +0 -0
  36. data/spec/dummy/script/rails +6 -0
  37. data/spec/models/chouette/access_link_spec.rb +78 -0
  38. data/spec/models/chouette/access_point_spec.rb +193 -0
  39. data/spec/models/chouette/active_record_spec.rb +121 -0
  40. data/spec/models/chouette/area_type_spec.rb +53 -0
  41. data/spec/models/chouette/company_spec.rb +51 -0
  42. data/spec/models/chouette/connection_link_spec.rb +56 -0
  43. data/spec/models/chouette/direction_spec.rb +60 -0
  44. data/spec/models/chouette/exporter_spec.rb +28 -0
  45. data/spec/models/chouette/file_validator_spec.rb +28 -0
  46. data/spec/models/chouette/group_of_line_spec.rb +31 -0
  47. data/spec/models/chouette/journey_pattern_spec.rb +62 -0
  48. data/spec/models/chouette/line_spec.rb +106 -0
  49. data/spec/models/chouette/loader_spec.rb +69 -0
  50. data/spec/models/chouette/network_spec.rb +22 -0
  51. data/spec/models/chouette/object_id_spec.rb +146 -0
  52. data/spec/models/chouette/route_spec.rb +159 -0
  53. data/spec/models/chouette/stop_area_spec.rb +354 -0
  54. data/spec/models/chouette/stop_point_spec.rb +39 -0
  55. data/spec/models/chouette/time_table_spec.rb +372 -0
  56. data/spec/models/chouette/transport_mode_spec.rb +64 -0
  57. data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +46 -0
  58. data/spec/models/chouette/vehicle_journey_spec.rb +204 -0
  59. data/spec/presenters/chouette/geometry/general_presenter.rb +1 -0
  60. data/spec/presenters/chouette/geometry/line_presenter_spec.rb +13 -0
  61. data/spec/spec_helper.rb +45 -0
  62. metadata +210 -130
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby1.8
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::AccessLink do
4
+ subject { Factory(:access_link) }
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 :link_type }
11
+ it { should validate_presence_of :link_orientation }
12
+
13
+ describe "#access_link_type" do
14
+
15
+ def self.legacy_link_types
16
+ %w{Underground Mixed Overground}
17
+ end
18
+
19
+ legacy_link_types.each do |link_type|
20
+ context "when link_type is #{link_type}" do
21
+ access_link_type = Chouette::ConnectionLinkType.new(link_type.underscore)
22
+ it "should be #{access_link_type}" do
23
+ subject.link_type = link_type
24
+ subject.access_link_type.should == access_link_type
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ describe "#access_link_type=" do
31
+
32
+ it "should change link_type with ConnectionLinkType#name" do
33
+ subject.access_link_type = "underground"
34
+ subject.link_type.should == "Underground"
35
+ end
36
+
37
+ end
38
+
39
+ describe "#link_orientation_type" do
40
+
41
+ def self.legacy_link_orientations
42
+ %w{AccessPointToStopArea StopAreaToAccessPoint}
43
+ end
44
+
45
+ legacy_link_orientations.each do |link_orientation|
46
+ context "when link_orientation is #{link_orientation}" do
47
+ link_orientation_type = Chouette::LinkOrientationType.new(link_orientation.underscore)
48
+ it "should be #{link_orientation_type}" do
49
+ subject.link_orientation = link_orientation
50
+ subject.link_orientation_type.should == link_orientation_type
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ describe "#link_orientation_type=" do
58
+
59
+ it "should change link_orientation with LinkOrientationType#name" do
60
+ subject.link_orientation_type = "access_point_to_stop_area"
61
+ subject.link_orientation.should == "AccessPointToStopArea"
62
+ end
63
+
64
+ end
65
+
66
+ describe "#link_key" do
67
+ it "should calculate link_key for access to area" do
68
+ subject.link_orientation_type = "access_point_to_stop_area"
69
+ subject.link_key.should == "A_#{subject.access_point.id}-S_#{subject.stop_area.id}"
70
+ end
71
+ it "should calculate link_key for area to access" do
72
+ subject.link_orientation_type = "stop_area_to_access_point"
73
+ subject.link_key.should == "S_#{subject.stop_area.id}-A_#{subject.access_point.id}"
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,193 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::AccessPoint do
4
+
5
+ its(:objectid) { should be_kind_of(Chouette::ObjectId) }
6
+
7
+ it { should validate_presence_of :name }
8
+ it { should validate_numericality_of :latitude }
9
+ it { should validate_numericality_of :longitude }
10
+
11
+ describe ".latitude" do
12
+ it "should accept -90 value" do
13
+ subject = Factory :access_point
14
+ subject.latitude = -90
15
+ subject.valid?.should be_true
16
+ end
17
+ it "should reject < -90 value" do
18
+ subject = Factory :access_point
19
+ subject.latitude = -90.0001
20
+ subject.valid?.should be_false
21
+ end
22
+ it "should accept 90 value" do
23
+ subject = Factory :access_point
24
+ subject.latitude = 90
25
+ subject.valid?.should be_true
26
+ end
27
+ it "should reject > 90 value" do
28
+ subject = Factory :access_point
29
+ subject.latitude = 90.0001
30
+ subject.valid?.should be_false
31
+ end
32
+ end
33
+
34
+ describe ".longitude" do
35
+ it "should accept -180 value" do
36
+ subject = Factory :access_point
37
+ subject.longitude = -180
38
+ subject.valid?.should be_true
39
+ end
40
+ it "should reject < -180 value" do
41
+ subject = Factory :access_point
42
+ subject.longitude = -180.0001
43
+ subject.valid?.should be_false
44
+ end
45
+ it "should accept 180 value" do
46
+ subject = Factory :access_point
47
+ subject.longitude = 180
48
+ subject.valid?.should be_true
49
+ end
50
+ it "should reject > 180 value" do
51
+ subject = Factory :access_point
52
+ subject.longitude = 180.0001
53
+ subject.valid?.should be_false
54
+ end
55
+ end
56
+
57
+ describe ".long_lat" do
58
+ it "should accept longitude and latitude both as nil" do
59
+ subject = Factory :access_point
60
+ subject.longitude = nil
61
+ subject.latitude = nil
62
+ subject.valid?.should be_true
63
+ end
64
+ it "should accept longitude and latitude both numerical" do
65
+ subject = Factory :access_point
66
+ subject.longitude = 10
67
+ subject.latitude = 10
68
+ subject.valid?.should be_true
69
+ end
70
+ it "should reject longitude nil with latitude numerical" do
71
+ subject = Factory :access_point
72
+ subject.longitude = nil
73
+ subject.latitude = 10
74
+ subject.valid?.should be_false
75
+ end
76
+ it "should reject longitude numerical with latitude nil" do
77
+ subject = Factory :access_point
78
+ subject.longitude = 10
79
+ subject.latitude = nil
80
+ subject.valid?.should be_false
81
+ end
82
+ end
83
+
84
+ describe "#access_type" do
85
+ def self.legacy_access_types
86
+ %w{In Out InOut}
87
+ end
88
+
89
+ legacy_access_types.each do |access_type|
90
+ context "when access_type is #{access_type}" do
91
+ access_point_type = Chouette::AccessPointType.new(access_type.underscore)
92
+ it "should be #{access_point_type}" do
93
+ subject.access_type = access_type
94
+ subject.access_point_type.should == access_point_type
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ describe "#access_point_type=" do
101
+ it "should change access_type with Chouette::AccessPointType#name" do
102
+ subject.access_point_type = "in_out"
103
+ subject.access_type.should == "InOut"
104
+ end
105
+
106
+ end
107
+
108
+ describe "#to_lat_lng" do
109
+
110
+ it "should return nil if latitude is nil" do
111
+ subject.latitude = nil
112
+ subject.to_lat_lng.should be_nil
113
+ end
114
+
115
+ it "should return nil if longitude is nil" do
116
+ subject.longitude = nil
117
+ subject.to_lat_lng.should be_nil
118
+ end
119
+
120
+ end
121
+
122
+ describe "#geometry" do
123
+
124
+ it "should be nil when to_lat_lng is nil" do
125
+ subject.stub :to_lat_lng => nil
126
+ subject.geometry.should be_nil
127
+ end
128
+
129
+ end
130
+
131
+ describe "#generic_access_link_matrix" do
132
+ it "should have 2 generic_access_links in matrix" do
133
+ stop_place = Factory :stop_area, :area_type => "StopPlace"
134
+ commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
135
+ subject = Factory :access_point, :stop_area => stop_place
136
+ subject.generic_access_link_matrix.size.should == 2
137
+ end
138
+
139
+ it "should have new generic_access_links in matrix" do
140
+ commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint"
141
+ subject = Factory :access_point, :stop_area => commercial_stop_point
142
+ subject.generic_access_link_matrix.each do |link|
143
+ link.id.should be_nil
144
+ end
145
+ end
146
+ it "should have only last generic_access_links as new in matrix" do
147
+ commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint"
148
+ subject = Factory :access_point, :stop_area => commercial_stop_point
149
+ link = Factory :access_link, :access_point => subject, :stop_area => commercial_stop_point
150
+ subject.generic_access_link_matrix.each do |link|
151
+ if link.link_key.start_with?"A_"
152
+ link.id.should_not be_nil
153
+ else
154
+ link.id.should be_nil
155
+ end
156
+ end
157
+ end
158
+ end
159
+
160
+ describe "#detail_access_link_matrix" do
161
+ it "should have 4 detail_access_links in matrix" do
162
+ stop_place = Factory :stop_area, :area_type => "StopPlace"
163
+ commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
164
+ quay1 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
165
+ quay2 = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
166
+ subject = Factory :access_point, :stop_area => stop_place
167
+ subject.detail_access_link_matrix.size.should == 4
168
+ end
169
+
170
+ it "should have new detail_access_links in matrix" do
171
+ commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint"
172
+ quay = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
173
+ subject = Factory :access_point, :stop_area => commercial_stop_point
174
+ subject.detail_access_link_matrix.each do |link|
175
+ link.id.should be_nil
176
+ end
177
+ end
178
+ it "should have only last detail_access_links as new in matrix" do
179
+ commercial_stop_point = Factory :stop_area, :area_type => "CommercialStopPoint"
180
+ quay = Factory :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
181
+ subject = Factory :access_point, :stop_area => commercial_stop_point
182
+ link = Factory :access_link, :access_point => subject, :stop_area => quay
183
+ subject.detail_access_link_matrix.each do |link|
184
+ if link.link_key.start_with?"A_"
185
+ link.id.should_not be_nil
186
+ else
187
+ link.id.should be_nil
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::ActiveRecord do
4
+
5
+ it { Chouette::ActiveRecord.ancestors.should include(ActiveRecord::Base) }
6
+
7
+ describe "table_name" do
8
+
9
+ it "should return line for Chouette::Line" do
10
+ Chouette::Line.table_name.should == "lines"
11
+ end
12
+
13
+ it "should return ptnetwork for Chouette::Network" do
14
+ Chouette::Network.table_name.should == "networks"
15
+ end
16
+
17
+ it "should return timetable_date for Chouette::TimeTableDate" do
18
+ Chouette::TimeTableDate.table_name.should == "time_table_dates"
19
+ end
20
+
21
+ it "should return timetable_period for Chouette::TimeTablePeriod" do
22
+ Chouette::TimeTablePeriod.table_name.should == "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
+ stop_area.area_type.should == 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
+ stop_area.respond_to?(:area_type).should be_true
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
+ Chouette::ActiveRecord::Reflection.stub :new => mock(:options_with_default => modified_options)
57
+ Chouette::ActiveRecord.should_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 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
+ subject.stub :macro => :has_many
79
+ subject.should be_collection
80
+ end
81
+
82
+ it "should be false when macro is belongs_to" do
83
+ subject.stub :macro => :belong_to
84
+ subject.should_not 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
+ subject.stub :name => "line"
93
+ subject.class_name.should == "Chouette::Line"
94
+ end
95
+
96
+ it "should be Chouette::Routes when name is routes and reflection is a collection" do
97
+ subject.stub :name => "routes", :collection? => true
98
+ subject.class_name.should == "Chouette::Route"
99
+ end
100
+
101
+ end
102
+
103
+
104
+ describe "options" do
105
+
106
+ it "should define class_name if not" do
107
+ subject.stub :options => {}, :class_name => "class_name"
108
+ subject.options_with_default[:class_name].should == "class_name"
109
+ end
110
+
111
+ it "should not define class_name if presents" do
112
+ subject.stub :options => {:class_name => "dummy"}
113
+ subject.options_with_default[:class_name].should == "dummy"
114
+ end
115
+
116
+ end
117
+
118
+
119
+ end
120
+
121
+
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::AreaType do
4
+
5
+ def mode(text_code = "test", numerical_code = nil)
6
+ numerical_code ||= 1 if text_code == "test"
7
+ Chouette::AreaType.new(text_code, numerical_code)
8
+ end
9
+
10
+ describe "#to_i" do
11
+
12
+ it "should return numerical code" do
13
+ mode("test", 1).to_i.should == 1
14
+ end
15
+
16
+ end
17
+
18
+ it "should return true to #test? when text code is 'test'" do
19
+ mode("test").should be_test
20
+ end
21
+
22
+ it "should be equal when text codes are identical" do
23
+ mode("test",1).should == mode("test", 2)
24
+ end
25
+
26
+ describe ".new" do
27
+
28
+ it "should find numerical code from text code" do
29
+ mode("boarding_position").to_i.should == 0
30
+ end
31
+
32
+ it "should find text code from numerical code" do
33
+ mode(0).should == "boarding_position"
34
+ end
35
+
36
+ it "should accept another mode" do
37
+ Chouette::AreaType.new(mode("test")).should == mode("test")
38
+ end
39
+
40
+ end
41
+
42
+
43
+ describe ".all" do
44
+
45
+ Chouette::AreaType.definitions.each do |text_code, numerical_code|
46
+ it "should include a AreaType #{text_code}" do
47
+ Chouette::AreaType.all.should include(Chouette::AreaType.new(text_code))
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::Company do
4
+
5
+ subject { Factory(:company) }
6
+
7
+ it { should validate_presence_of :registration_number }
8
+ it { should validate_uniqueness_of :registration_number }
9
+
10
+ it { should validate_presence_of :name }
11
+
12
+ # it { should validate_presence_of :objectid }
13
+ it { should validate_uniqueness_of :objectid }
14
+
15
+ describe "#nullables empty" do
16
+ it "should set null empty nullable attributes" do
17
+ subject.organizational_unit = ''
18
+ subject.operating_department_name = ''
19
+ subject.code = ''
20
+ subject.phone = ''
21
+ subject.fax = ''
22
+ subject.email = ''
23
+ subject.nil_if_blank
24
+ subject.organizational_unit.should be_nil
25
+ subject.operating_department_name.should be_nil
26
+ subject.code.should be_nil
27
+ subject.phone.should be_nil
28
+ subject.fax.should be_nil
29
+ subject.email.should be_nil
30
+ end
31
+ end
32
+
33
+ describe "#nullables non empty" do
34
+ it "should not set null non epmty nullable attributes" do
35
+ subject.organizational_unit = 'a'
36
+ subject.operating_department_name = 'b'
37
+ subject.code = 'c'
38
+ subject.phone = 'd'
39
+ subject.fax = 'z'
40
+ subject.email = 'r'
41
+ subject.nil_if_blank
42
+ subject.organizational_unit.should_not be_nil
43
+ subject.operating_department_name.should_not be_nil
44
+ subject.code.should_not be_nil
45
+ subject.phone.should_not be_nil
46
+ subject.fax.should_not be_nil
47
+ subject.email.should_not be_nil
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::ConnectionLink 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
+ subject { Factory(:connection_link) }
10
+
11
+ it { should validate_uniqueness_of :objectid }
12
+ its(:objectid) { should be_kind_of(Chouette::ObjectId) }
13
+
14
+ it { should validate_presence_of :name }
15
+
16
+ describe "#connection_link_type" do
17
+
18
+ def self.legacy_link_types
19
+ %w{Underground Mixed Overground}
20
+ end
21
+
22
+ legacy_link_types.each do |link_type|
23
+ context "when link_type is #{link_type}" do
24
+ connection_link_type = Chouette::ConnectionLinkType.new(link_type.underscore)
25
+ it "should be #{connection_link_type}" do
26
+ subject.link_type = link_type
27
+ subject.connection_link_type.should == connection_link_type
28
+ end
29
+ end
30
+ end
31
+ context "when link_type is nil" do
32
+ it "should be nil" do
33
+ subject.link_type = nil
34
+ subject.connection_link_type.should be_nil
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ describe "#connection_link_type=" do
41
+
42
+ it "should change link_type with ConnectionLinkType#name" do
43
+ subject.connection_link_type = "Test"
44
+ subject.link_type.should == "Test"
45
+ end
46
+
47
+ end
48
+
49
+ describe ".possible_areas" do
50
+
51
+ it "should not find areas type ITL" do
52
+ subject.possible_areas.should_not == [itl]
53
+ end
54
+ end
55
+
56
+ end