ninoxe 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/chouette/vehicle_journey_at_stop.rb +5 -5
- data/lib/ninoxe/version.rb +1 -1
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- 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.ru +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +19 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/locales/fr.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/schema.rb +490 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- 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 +82 -0
- data/spec/models/chouette/access_point_spec.rb +269 -0
- data/spec/models/chouette/active_record_spec.rb +121 -0
- data/spec/models/chouette/area_type_spec.rb +53 -0
- data/spec/models/chouette/company_spec.rb +48 -0
- data/spec/models/chouette/connection_link_spec.rb +60 -0
- data/spec/models/chouette/direction_spec.rb +60 -0
- data/spec/models/chouette/exporter_spec.rb +28 -0
- data/spec/models/chouette/file_validator_spec.rb +28 -0
- data/spec/models/chouette/footnote_spec.rb +9 -0
- data/spec/models/chouette/group_of_line_spec.rb +31 -0
- data/spec/models/chouette/journey_pattern_spec.rb +64 -0
- data/spec/models/chouette/line_spec.rb +120 -0
- data/spec/models/chouette/loader_spec.rb +69 -0
- data/spec/models/chouette/network_spec.rb +19 -0
- data/spec/models/chouette/object_id_spec.rb +149 -0
- data/spec/models/chouette/route_spec.rb +238 -0
- data/spec/models/chouette/stop_area_spec.rb +443 -0
- data/spec/models/chouette/stop_point_spec.rb +41 -0
- data/spec/models/chouette/time_table_period_spec.rb +66 -0
- data/spec/models/chouette/time_table_spec.rb +1266 -0
- data/spec/models/chouette/transport_mode_spec.rb +64 -0
- data/spec/models/chouette/trident_active_record_spec.rb +115 -0
- data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +47 -0
- data/spec/models/chouette/vehicle_journey_spec.rb +223 -0
- 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 +58 -0
- metadata +178 -10
- data/config/database.yml.me +0 -11
- data/lib/ninoxe.rb~ +0 -7
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::AreaType, :type => :model 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
|
+
expect(mode("test", 1).to_i).to eq(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return true to #test? when text code is 'test'" do
|
19
|
+
expect(mode("test")).to be_test
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be equal when text codes are identical" do
|
23
|
+
expect(mode("test",1)).to eq(mode("test", 2))
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".new" do
|
27
|
+
|
28
|
+
it "should find numerical code from text code" do
|
29
|
+
expect(mode("boarding_position").to_i).to eq(0)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should find text code from numerical code" do
|
33
|
+
expect(mode(0)).to eq("boarding_position")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should accept another mode" do
|
37
|
+
expect(Chouette::AreaType.new(mode("test"))).to eq(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
|
+
expect(Chouette::AreaType.all).to include(Chouette::AreaType.new(text_code))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::Company, :type => :model do
|
4
|
+
|
5
|
+
subject { create(:company) }
|
6
|
+
|
7
|
+
it { is_expected.to validate_presence_of :name }
|
8
|
+
|
9
|
+
# it { should validate_presence_of :objectid }
|
10
|
+
it { is_expected.to validate_uniqueness_of :objectid }
|
11
|
+
|
12
|
+
describe "#nullables empty" do
|
13
|
+
it "should set null empty nullable attributes" do
|
14
|
+
subject.organizational_unit = ''
|
15
|
+
subject.operating_department_name = ''
|
16
|
+
subject.code = ''
|
17
|
+
subject.phone = ''
|
18
|
+
subject.fax = ''
|
19
|
+
subject.email = ''
|
20
|
+
subject.nil_if_blank
|
21
|
+
expect(subject.organizational_unit).to be_nil
|
22
|
+
expect(subject.operating_department_name).to be_nil
|
23
|
+
expect(subject.code).to be_nil
|
24
|
+
expect(subject.phone).to be_nil
|
25
|
+
expect(subject.fax).to be_nil
|
26
|
+
expect(subject.email).to be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#nullables non empty" do
|
31
|
+
it "should not set null non epmty nullable attributes" do
|
32
|
+
subject.organizational_unit = 'a'
|
33
|
+
subject.operating_department_name = 'b'
|
34
|
+
subject.code = 'c'
|
35
|
+
subject.phone = 'd'
|
36
|
+
subject.fax = 'z'
|
37
|
+
subject.email = 'r'
|
38
|
+
subject.nil_if_blank
|
39
|
+
expect(subject.organizational_unit).not_to be_nil
|
40
|
+
expect(subject.operating_department_name).not_to be_nil
|
41
|
+
expect(subject.code).not_to be_nil
|
42
|
+
expect(subject.phone).not_to be_nil
|
43
|
+
expect(subject.fax).not_to be_nil
|
44
|
+
expect(subject.email).not_to be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::ConnectionLink, :type => :model do
|
4
|
+
let!(:quay) { create :stop_area, :area_type => "Quay" }
|
5
|
+
let!(:boarding_position) { create :stop_area, :area_type => "BoardingPosition" }
|
6
|
+
let!(:commercial_stop_point) { create :stop_area, :area_type => "CommercialStopPoint" }
|
7
|
+
let!(:stop_place) { create :stop_area, :area_type => "StopPlace" }
|
8
|
+
let!(:itl) { create :stop_area, :area_type => "ITL" }
|
9
|
+
subject { create(:connection_link) }
|
10
|
+
|
11
|
+
it { is_expected.to validate_uniqueness_of :objectid }
|
12
|
+
|
13
|
+
describe '#objectid' do
|
14
|
+
subject { super().objectid }
|
15
|
+
it { is_expected.to be_kind_of(Chouette::ObjectId) }
|
16
|
+
end
|
17
|
+
|
18
|
+
it { is_expected.to validate_presence_of :name }
|
19
|
+
|
20
|
+
describe "#connection_link_type" do
|
21
|
+
|
22
|
+
def self.legacy_link_types
|
23
|
+
%w{Underground Mixed Overground}
|
24
|
+
end
|
25
|
+
|
26
|
+
legacy_link_types.each do |link_type|
|
27
|
+
context "when link_type is #{link_type}" do
|
28
|
+
connection_link_type = Chouette::ConnectionLinkType.new(link_type.underscore)
|
29
|
+
it "should be #{connection_link_type}" do
|
30
|
+
subject.link_type = link_type
|
31
|
+
expect(subject.connection_link_type).to eq(connection_link_type)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
context "when link_type is nil" do
|
36
|
+
it "should be nil" do
|
37
|
+
subject.link_type = nil
|
38
|
+
expect(subject.connection_link_type).to be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#connection_link_type=" do
|
45
|
+
|
46
|
+
it "should change link_type with ConnectionLinkType#name" do
|
47
|
+
subject.connection_link_type = "Test"
|
48
|
+
expect(subject.link_type).to eq("Test")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".possible_areas" do
|
54
|
+
|
55
|
+
it "should not find areas type ITL" do
|
56
|
+
expect(subject.possible_areas).not_to eq([itl])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::Direction, :type => :model do
|
4
|
+
|
5
|
+
describe ".new" do
|
6
|
+
context "when single argument provided is a direction" do
|
7
|
+
let(:text) { "dummy"}
|
8
|
+
let(:direction){ Chouette::Direction.new( text, 1)}
|
9
|
+
it "should be equals to the provided direction" do
|
10
|
+
expect(direction).to eq(Chouette::Direction.new( direction))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
shared_examples_for "west direction" do
|
16
|
+
it "should return true to #west? " do
|
17
|
+
expect(direction).to be_west
|
18
|
+
end
|
19
|
+
context "#to_i" do
|
20
|
+
it "should return 6" do
|
21
|
+
expect(direction.to_i).to eq(6)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when instanciating with existing text only ('west' for example)" do
|
27
|
+
let(:direction){ Chouette::Direction.new "west"}
|
28
|
+
it_should_behave_like "west direction"
|
29
|
+
end
|
30
|
+
context "when instanciating with existing numerical code only (6 for example)" do
|
31
|
+
let(:direction){ Chouette::Direction.new 6}
|
32
|
+
it_should_behave_like "west direction"
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when instanciating with 'dummy' and 1 as argumrent" do
|
36
|
+
let(:text) { "dummy"}
|
37
|
+
let(:number) { 1}
|
38
|
+
let(:direction){ Chouette::Direction.new( text, number)}
|
39
|
+
|
40
|
+
it "should return true to #dummy? " do
|
41
|
+
expect(direction.send( "#{text}?".to_sym)).to be_truthy
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return false to #other-dummy? " do
|
45
|
+
expect(direction.send( "other-#{text}?".to_sym)).to be_falsey
|
46
|
+
end
|
47
|
+
|
48
|
+
context "#to_i" do
|
49
|
+
it "should return provided number" do
|
50
|
+
expect(direction.to_i).to eq(number)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "#name" do
|
55
|
+
it "should return provided text" do
|
56
|
+
expect(direction.name).to eq(text)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::Exporter, :type => :model do
|
4
|
+
|
5
|
+
subject { Chouette::Exporter.new("test") }
|
6
|
+
|
7
|
+
describe "#export" do
|
8
|
+
|
9
|
+
let(:chouette_command) { double :run! => true }
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
allow(subject).to receive_messages :chouette_command => chouette_command
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should use specified file in -outputFile option" do
|
16
|
+
expect(chouette_command).to receive(:run!).with(hash_including(:output_file => File.expand_path('file')))
|
17
|
+
subject.export "file"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should use specified format in -format option" do
|
21
|
+
expect(chouette_command).to receive(:run!).with(hash_including(:format => 'DUMMY'))
|
22
|
+
subject.export "file", :format => "dummy"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::FileValidator, :type => :model do
|
4
|
+
|
5
|
+
subject { Chouette::FileValidator.new("public") }
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
allow(subject).to receive_messages :execute! => true
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
describe "#validate" do
|
13
|
+
|
14
|
+
let(:chouette_command) { double :run! => true }
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
allow(subject).to receive_messages :chouette_command => chouette_command
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should use specified file in -inputFile option" do
|
21
|
+
expect(chouette_command).to receive(:run!).with(hash_including(:input_file => File.expand_path('file')))
|
22
|
+
subject.validate "file"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::GroupOfLine, :type => :model do
|
4
|
+
|
5
|
+
subject { create(:group_of_line) }
|
6
|
+
|
7
|
+
it { is_expected.to validate_presence_of :name }
|
8
|
+
|
9
|
+
# it { should validate_presence_of :objectid }
|
10
|
+
it { is_expected.to validate_uniqueness_of :objectid }
|
11
|
+
|
12
|
+
describe "#stop_areas" do
|
13
|
+
let!(:line){create(:line, :group_of_lines => [subject])}
|
14
|
+
let!(:route){create(:route, :line => line)}
|
15
|
+
it "should retreive group of line's stop_areas" do
|
16
|
+
expect(subject.stop_areas.count).to eq(route.stop_points.count)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "#line_tokens=" do
|
21
|
+
let!(:line1){create(:line)}
|
22
|
+
let!(:line2){create(:line)}
|
23
|
+
|
24
|
+
it "should return associated line ids" do
|
25
|
+
subject.update_attributes :line_tokens => [line1.id, line2.id].join(',')
|
26
|
+
expect(subject.lines).to include( line1)
|
27
|
+
expect(subject.lines).to include( line2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::JourneyPattern, :type => :model do
|
4
|
+
describe "#stop_point_ids" do
|
5
|
+
context "for a journey_pattern using only route's stop on odd position" do
|
6
|
+
let!(:journey_pattern){ create( :journey_pattern_odd)}
|
7
|
+
let!(:vehicle_journey){ create( :vehicle_journey_odd, :journey_pattern => journey_pattern)}
|
8
|
+
|
9
|
+
# workaroud
|
10
|
+
#subject { journey_pattern}
|
11
|
+
subject { Chouette::JourneyPattern.find(vehicle_journey.journey_pattern_id)}
|
12
|
+
|
13
|
+
context "when a all route's stop have been removed from journey_pattern" do
|
14
|
+
before(:each) do
|
15
|
+
subject.stop_point_ids = []
|
16
|
+
end
|
17
|
+
it "should remove all vehicle_journey_at_stop" do
|
18
|
+
vjas_stop_ids = Chouette::VehicleJourney.find(vehicle_journey.id).vehicle_journey_at_stops
|
19
|
+
expect(vjas_stop_ids.count).to eq(0)
|
20
|
+
end
|
21
|
+
it "should keep departure and arrival shortcut up to date to nil" do
|
22
|
+
expect(subject.arrival_stop_point_id).to be_nil
|
23
|
+
expect(subject.departure_stop_point_id).to be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when a route's stop has been removed from journey_pattern" do
|
28
|
+
let!(:last_stop_id){ subject.stop_point_ids.last}
|
29
|
+
before(:each) do
|
30
|
+
subject.stop_point_ids = subject.stop_point_ids - [last_stop_id]
|
31
|
+
end
|
32
|
+
it "should remove vehicle_journey_at_stop for last stop" do
|
33
|
+
vjas_stop_ids = Chouette::VehicleJourney.find(vehicle_journey.id).vehicle_journey_at_stops.map(&:stop_point_id)
|
34
|
+
expect(vjas_stop_ids.count).to eq(subject.stop_point_ids.size)
|
35
|
+
expect(vjas_stop_ids).not_to include( last_stop_id)
|
36
|
+
end
|
37
|
+
it "should keep departure and arrival shortcut up to date" do
|
38
|
+
ordered = subject.stop_points.sort { |a,b| a.position <=> b.position}
|
39
|
+
|
40
|
+
expect(subject.arrival_stop_point_id).to eq(ordered.last.id)
|
41
|
+
expect(subject.departure_stop_point_id).to eq(ordered.first.id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when a route's stop has been added in journey_pattern" do
|
46
|
+
let!(:new_stop){ subject.route.stop_points[1]}
|
47
|
+
before(:each) do
|
48
|
+
subject.stop_point_ids = subject.stop_point_ids + [new_stop.id]
|
49
|
+
end
|
50
|
+
it "should add a new vehicle_journey_at_stop for that stop" do
|
51
|
+
vjas_stop_ids = Chouette::VehicleJourney.find(vehicle_journey.id).vehicle_journey_at_stops.map(&:stop_point_id)
|
52
|
+
expect(vjas_stop_ids.count).to eq(subject.stop_point_ids.size)
|
53
|
+
expect(vjas_stop_ids).to include( new_stop.id)
|
54
|
+
end
|
55
|
+
it "should keep departure and arrival shortcut up to date" do
|
56
|
+
ordered = subject.stop_points.sort { |a,b| a.position <=> b.position}
|
57
|
+
|
58
|
+
expect(subject.arrival_stop_point_id).to eq(ordered.last.id)
|
59
|
+
expect(subject.departure_stop_point_id).to eq(ordered.first.id)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chouette::Line, :type => :model do
|
4
|
+
|
5
|
+
subject { create(:line) }
|
6
|
+
|
7
|
+
it { is_expected.to validate_presence_of :network }
|
8
|
+
it { is_expected.to validate_presence_of :company }
|
9
|
+
|
10
|
+
it { is_expected.to validate_presence_of :name }
|
11
|
+
|
12
|
+
# it { should validate_presence_of :objectid }
|
13
|
+
it { is_expected.to validate_uniqueness_of :objectid }
|
14
|
+
|
15
|
+
describe '#objectid' do
|
16
|
+
subject { super().objectid }
|
17
|
+
it { is_expected.to be_kind_of(Chouette::ObjectId) }
|
18
|
+
end
|
19
|
+
|
20
|
+
# it { should validate_numericality_of :objectversion }
|
21
|
+
|
22
|
+
describe ".last_stop_areas_parents" do
|
23
|
+
|
24
|
+
it "should return stop areas if no parents" do
|
25
|
+
line = create(:line_with_stop_areas)
|
26
|
+
expect(line.stop_areas_last_parents).to eq(line.stop_areas)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return stop areas parents if parents" do
|
30
|
+
line = create(:line_with_stop_areas)
|
31
|
+
route = create(:route, :line => line)
|
32
|
+
parent = create(:stop_area)
|
33
|
+
stop_areas = [ create(:stop_area), create(:stop_area), create(:stop_area, :parent_id => parent.id) ]
|
34
|
+
stop_areas.each do |stop_area|
|
35
|
+
create(:stop_point, :stop_area => stop_area, :route => route)
|
36
|
+
end
|
37
|
+
|
38
|
+
expect(line.stop_areas_last_parents).to match(line.stop_areas[0..(line.stop_areas.size - 2)].push(parent))
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#stop_areas" do
|
44
|
+
let!(:route){create(:route, :line => subject)}
|
45
|
+
it "should retreive route's stop_areas" do
|
46
|
+
expect(subject.stop_areas.count).to eq(route.stop_points.count)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#transport_mode" do
|
51
|
+
|
52
|
+
def self.legacy_transport_mode_names
|
53
|
+
%w{Air Train LongDistanceTrain LocalTrain RapidTransit Metro Tramway Coach Bus Ferry Waterborne PrivateVehicle Walk Trolleybus Bicycle Shuttle Taxi VAL Other}
|
54
|
+
end
|
55
|
+
|
56
|
+
legacy_transport_mode_names.each do |transport_mode_name|
|
57
|
+
context "when transport_mode_name is #{transport_mode_name}" do
|
58
|
+
transport_mode = Chouette::TransportMode.new(transport_mode_name.underscore)
|
59
|
+
it "should be #{transport_mode}" do
|
60
|
+
subject.transport_mode_name = transport_mode_name
|
61
|
+
expect(subject.transport_mode).to eq(transport_mode)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
context "when transport_mode_name is nil" do
|
66
|
+
it "should be nil" do
|
67
|
+
subject.transport_mode_name = nil
|
68
|
+
expect(subject.transport_mode).to be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#transport_mode=" do
|
75
|
+
|
76
|
+
it "should change transport_mode_name with TransportMode#name" do
|
77
|
+
subject.transport_mode = "Test"
|
78
|
+
expect(subject.transport_mode_name).to eq("Test")
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".transport_modes" do
|
84
|
+
|
85
|
+
it "should not include unknown transport_mode" do
|
86
|
+
expect(Chouette::Line.transport_modes).not_to include(Chouette::TransportMode.new("unknown"))
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should not include interchange transport_mode" do
|
90
|
+
expect(Chouette::Line.transport_modes).not_to include(Chouette::TransportMode.new("interchange"))
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
context "#group_of_line_tokens=" do
|
96
|
+
let!(:group_of_line1){create(:group_of_line)}
|
97
|
+
let!(:group_of_line2){create(:group_of_line)}
|
98
|
+
|
99
|
+
it "should return associated group_of_line ids" do
|
100
|
+
subject.update_attributes :group_of_line_tokens => [group_of_line1.id, group_of_line2.id].join(',')
|
101
|
+
expect(subject.group_of_lines).to include( group_of_line1)
|
102
|
+
expect(subject.group_of_lines).to include( group_of_line2)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#update_attributes footnotes_attributes" do
|
107
|
+
context "instanciate 2 footnotes without line" do
|
108
|
+
let!( :footnote_first) {build( :footnote, :line_id => nil)}
|
109
|
+
let!( :footnote_second) {build( :footnote, :line_id => nil)}
|
110
|
+
it "should add 2 footnotes to the line" do
|
111
|
+
subject.update_attributes :footnotes_attributes =>
|
112
|
+
{ Time.now.to_i => footnote_first.attributes,
|
113
|
+
(Time.now.to_i-5) => footnote_second.attributes}
|
114
|
+
expect(Chouette::Line.find( subject.id ).footnotes.size).to eq(2)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|