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,53 +0,0 @@
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
@@ -1,51 +0,0 @@
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 :registration_number }
8
- it { is_expected.to validate_uniqueness_of :registration_number }
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 "#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
- 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
- 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
- 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
- end
49
- end
50
-
51
- end
@@ -1,60 +0,0 @@
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
@@ -1,60 +0,0 @@
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
@@ -1,28 +0,0 @@
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
-
@@ -1,28 +0,0 @@
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
-
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chouette::Footnote do
4
-
5
- subject { build(:footnote) }
6
-
7
- it { should validate_presence_of :line }
8
-
9
- end
@@ -1,31 +0,0 @@
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
@@ -1,64 +0,0 @@
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
@@ -1,123 +0,0 @@
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 :registration_number }
11
- it { is_expected.to validate_uniqueness_of :registration_number }
12
-
13
- it { is_expected.to validate_presence_of :name }
14
-
15
- # it { should validate_presence_of :objectid }
16
- it { is_expected.to validate_uniqueness_of :objectid }
17
-
18
- describe '#objectid' do
19
- subject { super().objectid }
20
- it { is_expected.to be_kind_of(Chouette::ObjectId) }
21
- end
22
-
23
- # it { should validate_numericality_of :objectversion }
24
-
25
- describe ".last_stop_areas_parents" do
26
-
27
- it "should return stop areas if no parents" do
28
- line = create(:line_with_stop_areas)
29
- expect(line.stop_areas_last_parents).to eq(line.stop_areas)
30
- end
31
-
32
- it "should return stop areas parents if parents" do
33
- line = create(:line_with_stop_areas)
34
- route = create(:route, :line => line)
35
- parent = create(:stop_area)
36
- stop_areas = [ create(:stop_area), create(:stop_area), create(:stop_area, :parent_id => parent.id) ]
37
- stop_areas.each do |stop_area|
38
- create(:stop_point, :stop_area => stop_area, :route => route)
39
- end
40
-
41
- expect(line.stop_areas_last_parents).to match(line.stop_areas[0..(line.stop_areas.size - 2)].push(parent))
42
- end
43
-
44
- end
45
-
46
- describe "#stop_areas" do
47
- let!(:route){create(:route, :line => subject)}
48
- it "should retreive route's stop_areas" do
49
- expect(subject.stop_areas.count).to eq(route.stop_points.count)
50
- end
51
- end
52
-
53
- describe "#transport_mode" do
54
-
55
- def self.legacy_transport_mode_names
56
- %w{Air Train LongDistanceTrain LocalTrain RapidTransit Metro Tramway Coach Bus Ferry Waterborne PrivateVehicle Walk Trolleybus Bicycle Shuttle Taxi VAL Other}
57
- end
58
-
59
- legacy_transport_mode_names.each do |transport_mode_name|
60
- context "when transport_mode_name is #{transport_mode_name}" do
61
- transport_mode = Chouette::TransportMode.new(transport_mode_name.underscore)
62
- it "should be #{transport_mode}" do
63
- subject.transport_mode_name = transport_mode_name
64
- expect(subject.transport_mode).to eq(transport_mode)
65
- end
66
- end
67
- end
68
- context "when transport_mode_name is nil" do
69
- it "should be nil" do
70
- subject.transport_mode_name = nil
71
- expect(subject.transport_mode).to be_nil
72
- end
73
- end
74
-
75
- end
76
-
77
- describe "#transport_mode=" do
78
-
79
- it "should change transport_mode_name with TransportMode#name" do
80
- subject.transport_mode = "Test"
81
- expect(subject.transport_mode_name).to eq("Test")
82
- end
83
-
84
- end
85
-
86
- describe ".transport_modes" do
87
-
88
- it "should not include unknown transport_mode" do
89
- expect(Chouette::Line.transport_modes).not_to include(Chouette::TransportMode.new("unknown"))
90
- end
91
-
92
- it "should not include interchange transport_mode" do
93
- expect(Chouette::Line.transport_modes).not_to include(Chouette::TransportMode.new("interchange"))
94
- end
95
-
96
- end
97
-
98
- context "#group_of_line_tokens=" do
99
- let!(:group_of_line1){create(:group_of_line)}
100
- let!(:group_of_line2){create(:group_of_line)}
101
-
102
- it "should return associated group_of_line ids" do
103
- subject.update_attributes :group_of_line_tokens => [group_of_line1.id, group_of_line2.id].join(',')
104
- expect(subject.group_of_lines).to include( group_of_line1)
105
- expect(subject.group_of_lines).to include( group_of_line2)
106
- end
107
- end
108
-
109
- describe "#update_attributes footnotes_attributes" do
110
- context "instanciate 2 footnotes without line" do
111
- let!( :footnote_first) {build( :footnote, :line_id => nil)}
112
- let!( :footnote_second) {build( :footnote, :line_id => nil)}
113
- it "should add 2 footnotes to the line" do
114
- subject.update_attributes :footnotes_attributes =>
115
- { Time.now.to_i => footnote_first.attributes,
116
- (Time.now.to_i-5) => footnote_second.attributes}
117
- Chouette::Line.find( subject.id ).footnotes.size.should == 2
118
- end
119
- end
120
- end
121
-
122
-
123
- end