ninoxe 0.1.2 → 0.1.3
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.
- data/README.md +4 -0
- data/app/models/chouette/access_link.rb +5 -1
- data/app/models/chouette/access_point.rb +14 -10
- data/app/models/chouette/connection_link.rb +5 -1
- data/app/models/chouette/group_of_line.rb +1 -1
- data/app/models/chouette/journey_pattern.rb +1 -1
- data/app/models/chouette/line.rb +5 -1
- data/app/models/chouette/mobility_need.rb +4 -0
- data/app/models/chouette/network.rb +1 -1
- data/app/models/chouette/pt_link.rb +1 -1
- data/app/models/chouette/route.rb +5 -1
- data/app/models/chouette/stop_area.rb +21 -13
- data/app/models/chouette/stop_point.rb +1 -1
- data/app/models/chouette/suitability.rb +5 -0
- data/app/models/chouette/time_table.rb +11 -2
- 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 +1 -1
- data/app/models/chouette/vehicle_journey_at_stop.rb +1 -1
- data/app/presenters/chouette/geometry/access_link_presenter.rb +11 -0
- data/app/presenters/chouette/geometry/access_point_presenter.rb +11 -0
- data/app/presenters/chouette/geometry/connection_link_presenter.rb +11 -0
- data/app/presenters/chouette/geometry/general_presenter.rb +20 -0
- data/app/presenters/chouette/geometry/line_presenter.rb +42 -0
- data/app/presenters/chouette/geometry/route_presenter.rb +22 -0
- data/app/presenters/chouette/geometry/stop_area_presenter.rb +13 -0
- data/db/migrate/20130628124932_remove_projection_from_stop_areas.rb +19 -0
- data/db/migrate/20130628124951_remove_projection_from_access_points.rb +19 -0
- data/db/migrate/20130708081951_add_accessibility_to_stop_areas.rb +30 -0
- data/db/migrate/20130710122648_set_accessibiliity_to_existing_stop_area.rb +16 -0
- data/lib/factories/chouette_lines.rb +11 -0
- data/lib/ninoxe/version.rb +1 -1
- data/spec/models/chouette/access_point_spec.rb +0 -29
- data/spec/models/chouette/stop_area_spec.rb +0 -28
- data/spec/models/chouette/time_table_spec.rb +35 -13
- data/spec/presenters/chouette/geometry/general_presenter.rb +1 -0
- data/spec/presenters/chouette/geometry/line_presenter_spec.rb +13 -0
- data/spec/spec_helper.rb +0 -17
- metadata +242 -206
- data/README.rdoc +0 -3
@@ -10,14 +10,14 @@ describe Chouette::TimeTable do
|
|
10
10
|
describe "#periods_max_date" do
|
11
11
|
context "when all period extends from 04/10/2013 to 04/15/2013," do
|
12
12
|
before(:each) do
|
13
|
-
p1 = Chouette::TimeTablePeriod.new( :period_start => Date.
|
14
|
-
p2 = Chouette::TimeTablePeriod.new( :period_start => Date.
|
13
|
+
p1 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/10/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/12/2013", '%m/%d/%Y'))
|
14
|
+
p2 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/13/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/15/2013", '%m/%d/%Y'))
|
15
15
|
subject.periods = [ p1, p2]
|
16
16
|
subject.save
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should retreive 04/15/2013" do
|
20
|
-
subject.periods_max_date.should == Date.
|
20
|
+
subject.periods_max_date.should == Date.strptime("04/15/2013", '%m/%d/%Y')
|
21
21
|
end
|
22
22
|
context "when day_types select only sunday and saturday," do
|
23
23
|
before(:each) do
|
@@ -25,7 +25,7 @@ describe Chouette::TimeTable do
|
|
25
25
|
subject.update_attributes( :int_day_types => (2**(1+6) + 2**(1+7)))
|
26
26
|
end
|
27
27
|
it "should retreive 04/14/2013" do
|
28
|
-
subject.periods_max_date.should == Date.
|
28
|
+
subject.periods_max_date.should == Date.strptime("04/14/2013", '%m/%d/%Y')
|
29
29
|
end
|
30
30
|
end
|
31
31
|
context "when day_types select only friday," do
|
@@ -34,7 +34,7 @@ describe Chouette::TimeTable do
|
|
34
34
|
subject.update_attributes( :int_day_types => (2**(1+6)))
|
35
35
|
end
|
36
36
|
it "should retreive 04/12/2013" do
|
37
|
-
subject.periods_max_date.should == Date.
|
37
|
+
subject.periods_max_date.should == Date.strptime("04/13/2013", '%m/%d/%Y')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
context "when day_types select only thursday," do
|
@@ -52,14 +52,14 @@ describe Chouette::TimeTable do
|
|
52
52
|
describe "#periods_min_date" do
|
53
53
|
context "when all period extends from 04/10/2013 to 04/15/2013," do
|
54
54
|
before(:each) do
|
55
|
-
p1 = Chouette::TimeTablePeriod.new( :period_start => Date.
|
56
|
-
p2 = Chouette::TimeTablePeriod.new( :period_start => Date.
|
55
|
+
p1 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/10/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/12/2013", '%m/%d/%Y'))
|
56
|
+
p2 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/13/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/15/2013", '%m/%d/%Y'))
|
57
57
|
subject.periods = [ p1, p2]
|
58
58
|
subject.save
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should retreive 04/10/2013" do
|
62
|
-
subject.periods_min_date.should == Date.
|
62
|
+
subject.periods_min_date.should == Date.strptime("04/10/2013", '%m/%d/%Y')
|
63
63
|
end
|
64
64
|
context "when day_types select only tuesday and friday," do
|
65
65
|
before(:each) do
|
@@ -67,7 +67,7 @@ describe Chouette::TimeTable do
|
|
67
67
|
subject.update_attributes( :int_day_types => (2**(1+4) + 2**(1+5)))
|
68
68
|
end
|
69
69
|
it "should retreive 04/11/2013" do
|
70
|
-
subject.periods_min_date.should == Date.
|
70
|
+
subject.periods_min_date.should == Date.strptime("04/11/2013", '%m/%d/%Y')
|
71
71
|
end
|
72
72
|
end
|
73
73
|
context "when day_types select only friday," do
|
@@ -76,7 +76,7 @@ describe Chouette::TimeTable do
|
|
76
76
|
subject.update_attributes( :int_day_types => (2**(1+5)))
|
77
77
|
end
|
78
78
|
it "should retreive 04/12/2013" do
|
79
|
-
subject.periods_min_date.should == Date.
|
79
|
+
subject.periods_min_date.should == Date.strptime("04/12/2013", '%m/%d/%Y')
|
80
80
|
end
|
81
81
|
end
|
82
82
|
context "when day_types select only thursday," do
|
@@ -177,6 +177,28 @@ describe Chouette::TimeTable do
|
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
+
describe "#intersects" do
|
181
|
+
it "should return day if a date equal day" do
|
182
|
+
time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
|
183
|
+
time_table_date = Factory(:time_table_date, :date => Date.today, :time_table_id => time_table.id)
|
184
|
+
time_table.intersects([Date.today]).should == [Date.today]
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should return [] if a period not include days" do
|
188
|
+
time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12)
|
189
|
+
time_table_period = Factory(:time_table_period, :period_start => Date.new(2013, 05, 27),:period_end => Date.new(2013, 05, 30), :time_table_id => time_table.id)
|
190
|
+
time_table.intersects([ Date.new(2013, 05, 29), Date.new(2013, 05, 30)]).should == []
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should return days if a period include day" do
|
194
|
+
time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12) # Day type monday and tuesday
|
195
|
+
time_table_period = Factory(:time_table_period, :period_start => Date.new(2013, 05, 27),:period_end => Date.new(2013, 05, 30), :time_table_id => time_table.id)
|
196
|
+
time_table.intersects([ Date.new(2013, 05, 27), Date.new(2013, 05, 28)]).should == [ Date.new(2013, 05, 27), Date.new(2013, 05, 28)]
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
end
|
201
|
+
|
180
202
|
describe "#include_day?" do
|
181
203
|
it "should return true if a date equal day" do
|
182
204
|
time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
|
@@ -185,9 +207,9 @@ describe Chouette::TimeTable do
|
|
185
207
|
end
|
186
208
|
|
187
209
|
it "should return true if a period include day" do
|
188
|
-
time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
|
189
|
-
time_table_period = Factory(:time_table_period, :period_start => Date.
|
190
|
-
time_table.include_day?(Date.
|
210
|
+
time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12) # Day type monday and tuesday
|
211
|
+
time_table_period = Factory(:time_table_period, :period_start => Date.new(2013, 05, 27),:period_end => Date.new(2013, 05, 29), :time_table_id => time_table.id)
|
212
|
+
time_table.include_day?( Date.new(2013, 05, 27)).should == true
|
191
213
|
end
|
192
214
|
end
|
193
215
|
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::Geometry::LinePresenter do
|
4
|
+
let!(:line) { Factory(:line_with_stop_areas_having_parent) }
|
5
|
+
subject { Chouette::Geometry::LinePresenter.new(line)}
|
6
|
+
|
7
|
+
describe "#routes_localized_commercials" do
|
8
|
+
it "should return 3 stop_areas" do
|
9
|
+
subject.routes_localized_commercials(line.routes.first).size.should == 5
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,6 @@ require 'rspec/autorun'
|
|
8
8
|
require 'shoulda-matchers'
|
9
9
|
require 'factory_girl_rails'
|
10
10
|
|
11
|
-
require 'database_cleaner'
|
12
11
|
require 'geo_ruby'
|
13
12
|
|
14
13
|
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
@@ -19,7 +18,6 @@ Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
|
19
18
|
Dir[File.join(ENGINE_RAILS_ROOT, "lib/factories/**/*.rb")].each {|f| require f }
|
20
19
|
|
21
20
|
RSpec.configure do |config|
|
22
|
-
DatabaseCleaner.logger = Rails.logger
|
23
21
|
# == Mock Framework
|
24
22
|
#
|
25
23
|
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
@@ -42,21 +40,6 @@ RSpec.configure do |config|
|
|
42
40
|
# rspec-rails.
|
43
41
|
config.infer_base_class_for_anonymous_controllers = false
|
44
42
|
|
45
|
-
config.before(:suite) do
|
46
|
-
DatabaseCleaner.strategy = :transaction
|
47
|
-
#DatabaseCleaner.clean_with( :truncation, {:except => %w[spatial_ref_sys geometry_columns]} )
|
48
|
-
|
49
|
-
Chouette::ActiveRecord.logger = Logger.new("log/test.log")
|
50
|
-
end
|
51
|
-
|
52
|
-
config.before(:each) do
|
53
|
-
DatabaseCleaner.start
|
54
|
-
end
|
55
|
-
|
56
|
-
config.after(:each) do
|
57
|
-
DatabaseCleaner.clean
|
58
|
-
end
|
59
|
-
|
60
43
|
end
|
61
44
|
|
62
45
|
|